From 5622ce97e5ad4a05e4d80186cdddd7ca6ca775ea Mon Sep 17 00:00:00 2001 From: Heaven Date: Thu, 7 May 2026 16:59:19 +0200 Subject: [PATCH] Better clean :D --- src/Output.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Output.cpp b/src/Output.cpp index 30542d6..c798fb3 100644 --- a/src/Output.cpp +++ b/src/Output.cpp @@ -6,6 +6,7 @@ #include "fmt/base.h" #include "fmt/color.h" #include +#include 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" );