Changed the conditions for firing 'No such file or directory' error
This commit is contained in:
parent
ca25c6e0a3
commit
43264bff23
1 changed files with 22 additions and 13 deletions
|
@ -622,32 +622,41 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
|
||||||
args.push_back(path);
|
args.push_back(path);
|
||||||
args.push_front("trash"); // The command is `gio trash <file_name>` so we need to add it to args.
|
args.push_front("trash"); // The command is `gio trash <file_name>` so we need to add it to args.
|
||||||
Error result = execute("gio", args, nullptr, &err_code); // For GNOME based machines.
|
Error result = execute("gio", args, nullptr, &err_code); // For GNOME based machines.
|
||||||
if (result == OK && !err_code) {
|
if (result == OK) { // The `execute` function has done its job without errors.
|
||||||
return OK;
|
if (!err_code) { // The shell command has been executed without errors.
|
||||||
} else if (err_code == 2) {
|
return OK;
|
||||||
return ERR_FILE_NOT_FOUND;
|
} else if (err_code == 1) {
|
||||||
|
ERR_PRINT("move_to_trash: No such file or directory as " + path + ".");
|
||||||
|
return ERR_FILE_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args.pop_front();
|
args.pop_front();
|
||||||
args.push_front("move");
|
args.push_front("move");
|
||||||
args.push_back("trash:/"); // The command is `kioclient5 move <file_name> trash:/`.
|
args.push_back("trash:/"); // The command is `kioclient5 move <file_name> trash:/`.
|
||||||
result = execute("kioclient5", args, nullptr, &err_code); // For KDE based machines.
|
result = execute("kioclient5", args, nullptr, &err_code); // For KDE based machines.
|
||||||
if (result == OK && !err_code) {
|
if (result == OK) { // The `execute` function has done its job without errors.
|
||||||
return OK;
|
if (!err_code) { // The shell command has been executed without errors.
|
||||||
} else if (err_code == 2) {
|
return OK;
|
||||||
return ERR_FILE_NOT_FOUND;
|
} else if (err_code == 1) {
|
||||||
|
ERR_PRINT("move_to_trash: No such file or directory as " + path + ".");
|
||||||
|
return ERR_FILE_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args.pop_front();
|
args.pop_front();
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
result = execute("gvfs-trash", args, nullptr, &err_code); // For older Linux machines.
|
result = execute("gvfs-trash", args, nullptr, &err_code); // For older Linux machines.
|
||||||
if (result == OK && !err_code) {
|
if (result == OK) { // The `execute` function has done its job without errors.
|
||||||
return OK;
|
if (!err_code) { // The shell command has been executed without errors.
|
||||||
} else if (err_code == 2) {
|
return OK;
|
||||||
return ERR_FILE_NOT_FOUND;
|
} else if (err_code == 1) {
|
||||||
|
ERR_PRINT("move_to_trash: No such file or directory as " + path + ".");
|
||||||
|
return ERR_FILE_NOT_FOUND;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the commands `kioclient5`, `gio` or `gvfs-trash` don't exist on the system we do it manually.
|
// If the commands `kioclient5`, `gio` or `gvfs-trash` don't work on the system we do it manually.
|
||||||
String trash_path = "";
|
String trash_path = "";
|
||||||
String mnt = get_mountpoint(path);
|
String mnt = get_mountpoint(path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue