mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
HackStudio: Implement removing file from disk
This commit is contained in:
parent
c7777ff289
commit
ee7c8fbd7b
1 changed files with 21 additions and 4 deletions
|
@ -376,15 +376,32 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (auto& file : files) {
|
for (auto& file : files) {
|
||||||
if (1) {
|
struct stat st;
|
||||||
// FIXME: Remove `file` from disk
|
if (lstat(file.characters(), &st) < 0) {
|
||||||
} else {
|
|
||||||
GUI::MessageBox::show(window(),
|
GUI::MessageBox::show(window(),
|
||||||
String::formatted("Removing file {} from the project failed.", file),
|
String::formatted("lstat ({}) failed: {}", file, strerror(errno)),
|
||||||
"Removal failed",
|
"Removal failed",
|
||||||
GUI::MessageBox::Type::Error);
|
GUI::MessageBox::Type::Error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_directory = S_ISDIR(st.st_mode);
|
||||||
|
auto result = Core::File::remove(file, Core::File::RecursionMode::Allowed, false);
|
||||||
|
if (result.is_error()) {
|
||||||
|
auto& error = result.error();
|
||||||
|
if (is_directory) {
|
||||||
|
GUI::MessageBox::show(window(),
|
||||||
|
String::formatted("Removing directory {} from the project failed: {}", error.file, error.error_code),
|
||||||
|
"Removal failed",
|
||||||
|
GUI::MessageBox::Type::Error);
|
||||||
|
} else {
|
||||||
|
GUI::MessageBox::show(window(),
|
||||||
|
String::formatted("Removing file {} from the project failed: {}", error.file, error.error_code),
|
||||||
|
"Removal failed",
|
||||||
|
GUI::MessageBox::Type::Error);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
delete_action->set_enabled(false);
|
delete_action->set_enabled(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue