Better clean :D
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "fmt/base.h"
|
||||
#include "fmt/color.h"
|
||||
#include <cstdlib>
|
||||
#include <system_error>
|
||||
|
||||
namespace Output {
|
||||
void printMenu() {
|
||||
@@ -39,18 +40,30 @@ namespace Output {
|
||||
|
||||
void printArgClean() {
|
||||
std::filesystem::path dirPath = "build";
|
||||
std::error_code errorCode;
|
||||
|
||||
if (!std::filesystem::exists(dirPath) || !std::filesystem::is_directory(dirPath)) {
|
||||
if (!std::filesystem::exists(dirPath, errorCode) || !std::filesystem::is_directory(dirPath, errorCode)) {
|
||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
||||
"[Lazymake] Cleanup failed. Nothing to clean :(\n"
|
||||
);
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
std::filesystem::remove_all(dirPath, errorCode);
|
||||
|
||||
std::filesystem::remove_all(dirPath);
|
||||
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
|
||||
// std::filesystem::remove_all(entry.path());
|
||||
// }
|
||||
|
||||
if (errorCode) {
|
||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
||||
"[Lazymake] Error! Could not clean up build directory :(\n {}\n", errorCode.message()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
std::filesystem::create_directory(dirPath, errorCode);
|
||||
|
||||
fmt::print(fmt::fg(fmt::color::light_green),
|
||||
"[Lazymake] Cleaned up build directory :D\n"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user