Skip to content

Commit

Permalink
util: prompt before nuking out directory
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Mar 9, 2024
1 parent a5cfddb commit 2e42262
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions hyprcursor-util/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SCursorTheme> currentTheme;

static Hyprlang::CParseResult parseDefineSize(const char* C, const char* V) {
Expand Down Expand Up @@ -181,7 +197,7 @@ static std::optional<std::string> 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);
}

Expand Down Expand Up @@ -265,7 +281,7 @@ static std::optional<std::string> 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);
}

Expand Down

0 comments on commit 2e42262

Please sign in to comment.