mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
FileManager: Added support for deleting directories
Directories can now be deleted using the "Delete..." action from the context menu
This commit is contained in:
parent
9009390f9c
commit
09189e34e3
Notes:
sideshowbarker
2024-07-19 11:06:48 +09:00
Author: https://github.com/tlmrgvf
Commit: 09189e34e3
Pull-request: https://github.com/SerenityOS/serenity/pull/815
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/bugaevc
3 changed files with 66 additions and 3 deletions
|
@ -252,8 +252,33 @@ int main(int argc, char** argv)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& path : paths) {
|
||||
if (unlink(path.characters()) < 0) {
|
||||
struct stat st;
|
||||
if (lstat(path.characters(), &st)) {
|
||||
GMessageBox::show(
|
||||
String::format("lstat(%s) failed: %s", path.characters(), strerror(errno)),
|
||||
"Delete failed",
|
||||
GMessageBox::Type::Error,
|
||||
GMessageBox::InputType::OK,
|
||||
window);
|
||||
break;
|
||||
}
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
String error_path;
|
||||
int error = FileUtils::delete_directory(path, error_path);
|
||||
|
||||
if (error) {
|
||||
GMessageBox::show(
|
||||
String::format("Failed to delete directory \"%s\": %s", error_path.characters(), strerror(error)),
|
||||
"Delete failed",
|
||||
GMessageBox::Type::Error,
|
||||
GMessageBox::InputType::OK,
|
||||
window);
|
||||
break;
|
||||
}
|
||||
} else if (unlink(path.characters()) < 0) {
|
||||
int saved_errno = errno;
|
||||
GMessageBox::show(
|
||||
String::format("unlink(%s) failed: %s", path.characters(), strerror(saved_errno)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue