Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/elfmz/far2l.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/far2l/src
diff options
context:
space:
mode:
Diffstat (limited to 'far2l/src')
-rw-r--r--far2l/src/delete.cpp29
-rw-r--r--far2l/src/message.cpp12
-rw-r--r--far2l/src/message.hpp1
3 files changed, 35 insertions, 7 deletions
diff --git a/far2l/src/delete.cpp b/far2l/src/delete.cpp
index 391e6731..4aacf5da 100644
--- a/far2l/src/delete.cpp
+++ b/far2l/src/delete.cpp
@@ -801,25 +801,40 @@ int ERemoveDirectory(const wchar_t *Name,int Wipe)
return DELETE_SUCCESS;
}
-int RemoveToRecycleBin(const wchar_t *Name)
+static int RemoveToRecycleBin(const wchar_t *Name)
{
- std::string name_mb = Wide2MB(Name);
+ FARString err_file;
+ FarMkTempEx(err_file, L"trash");
+
+ std::string name_arg = Wide2MB(Name);
+ std::string err_file_arg = err_file.GetMB();
unsigned int flags = EF_HIDEOUT;
- if (sudo_client_is_required_for(name_mb.c_str(), true))
+ if (sudo_client_is_required_for(name_arg.c_str(), true))
flags|= EF_SUDO;
- QuoteCmdArgIfNeed(name_mb);
+ QuoteCmdArgIfNeed(name_arg);
+ QuoteCmdArgIfNeed(err_file_arg);
std::string cmd = GetMyScriptQuoted("trash.sh");
cmd+= ' ';
- cmd+= name_mb;
+ cmd+= name_arg;
+ cmd+= ' ';
+ cmd+= err_file_arg;
int r = farExecuteA(cmd.c_str(), flags);
- if (r==0)
+ if (r == 0)
return TRUE;
- errno = r;
+ std::string err_str;
+ if (ReadWholeFile(err_file.GetMB().c_str(), err_str, 0x10000)) {
+ // gio: file:///.../xxx/yyy: Unable to trash file .../xxx/yyy: Permission denied
+ err_str.erase(0, err_str.rfind(':') + 1);
+ StrTrim(err_str, " \t\r\n");
+ SetErrorString(err_str);
+ }
+ unlink(err_file.GetMB().c_str());
+
return FALSE;
}
diff --git a/far2l/src/message.cpp b/far2l/src/message.cpp
index e2e273dc..3072e5d6 100644
--- a/far2l/src/message.cpp
+++ b/far2l/src/message.cpp
@@ -566,9 +566,16 @@ void GetMessagePosition(int &X1,int &Y1,int &X2,int &Y2)
Y2=MessageY2;
}
+static FARString s_ErrorString;
+
bool GetErrorString(FARString &strErrStr)
{
auto err = errno;
+ if (err == -1 && !s_ErrorString.IsEmpty()) {
+ strErrStr = s_ErrorString;
+ return true;
+ }
+
const char *str = strerror(err);
if (str) {
strErrStr.Format(L"%s (%u)", str, err);
@@ -578,6 +585,11 @@ bool GetErrorString(FARString &strErrStr)
return true;
}
+void SetErrorString(const FARString &strErrStr)
+{
+ s_ErrorString = strErrStr;
+ errno = -1;
+}
void SetMessageHelp(const wchar_t *Topic)
{
diff --git a/far2l/src/message.hpp b/far2l/src/message.hpp
index ee091471..ab5ba49e 100644
--- a/far2l/src/message.hpp
+++ b/far2l/src/message.hpp
@@ -93,3 +93,4 @@ void GetMessagePosition(int &X1,int &Y1,int &X2,int &Y2);
int AbortMessage();
bool GetErrorString(FARString &strErrStr);
+void SetErrorString(const FARString &strErrStr);