diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 10:26:50 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 10:26:50 +0200 |
| commit | 01e84b1da126026742fa769624332865d070539e (patch) | |
| tree | 469cf58759bfe3618147421432dddb23b899cab0 /platform/linuxbsd | |
| parent | 116f783db73f4bf7e9e96ae54dd3d0a20337cc8a (diff) | |
| parent | 43264bff23b53effe2a2b1d3a449fc7074f43cef (diff) | |
| download | redot-engine-01e84b1da126026742fa769624332865d070539e.tar.gz | |
Merge pull request #67158 from amoriqbal/fix_error_message
Fix the conditions for firing 'No such file or directory' error on Linux `move_to_trash`
Diffstat (limited to 'platform/linuxbsd')
| -rw-r--r-- | platform/linuxbsd/os_linuxbsd.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 35807875a5..310778388b 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -961,32 +961,41 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) { args.push_back(path); 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. - if (result == OK && !err_code) { - return OK; - } else if (err_code == 2) { - return ERR_FILE_NOT_FOUND; + if (result == OK) { // The `execute` function has done its job without errors. + if (!err_code) { // The shell command has been executed without errors. + return OK; + } 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.push_front("move"); args.push_back("trash:/"); // The command is `kioclient5 move <file_name> trash:/`. result = execute("kioclient5", args, nullptr, &err_code); // For KDE based machines. - if (result == OK && !err_code) { - return OK; - } else if (err_code == 2) { - return ERR_FILE_NOT_FOUND; + if (result == OK) { // The `execute` function has done its job without errors. + if (!err_code) { // The shell command has been executed without errors. + return OK; + } 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_back(); result = execute("gvfs-trash", args, nullptr, &err_code); // For older Linux machines. - if (result == OK && !err_code) { - return OK; - } else if (err_code == 2) { - return ERR_FILE_NOT_FOUND; + if (result == OK) { // The `execute` function has done its job without errors. + if (!err_code) { // The shell command has been executed without errors. + return OK; + } 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 mnt = get_mountpoint(path); |
