From 2e42262ac57076ded579cae0f8435c8bbbcfb986 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 9 Mar 2024 21:44:47 +0000 Subject: [PATCH] util: prompt before nuking out directory --- hyprcursor-util/src/main.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/hyprcursor-util/src/main.cpp b/hyprcursor-util/src/main.cpp index 305294d..5755732 100644 --- a/hyprcursor-util/src/main.cpp +++ b/hyprcursor-util/src/main.cpp @@ -38,6 +38,22 @@ static std::string removeBeginEndSpacesTabs(std::string str) { return str; } +static bool promptForDeletion(const std::string& path) { + std::cout << "About to delete (recursively) " << path << ", are you sure? [Y/n]\n"; + std::string result; + std::cin >> result; + + if (result != "Y" && result != "Y\n" && result != "y\n" && result != "y") { + std::cout << "Abort.\n"; + exit(1); + return false; + } + + std::filesystem::remove_all(path); + + return true; +} + std::unique_ptr currentTheme; static Hyprlang::CParseResult parseDefineSize(const char* C, const char* V) { @@ -181,7 +197,7 @@ static std::optional createCursorThemeFromPath(const std::string& p std::filesystem::create_directory(out); else { // clear the entire thing, avoid melting themes together - std::filesystem::remove_all(out); + promptForDeletion(out); std::filesystem::create_directory(out); } @@ -265,7 +281,7 @@ static std::optional extractXTheme(const std::string& xpath, const std::filesystem::create_directory(out); else { // clear the entire thing, avoid melting themes together - std::filesystem::remove_all(out); + promptForDeletion(out); std::filesystem::create_directory(out); }