summaryrefslogtreecommitdiff
path: root/zen
diff options
context:
space:
mode:
Diffstat (limited to 'zen')
-rw-r--r--zen/file_access.cpp21
-rw-r--r--zen/http.cpp12
-rw-r--r--zen/zstring.h6
3 files changed, 32 insertions, 7 deletions
diff --git a/zen/file_access.cpp b/zen/file_access.cpp
index 4ce66acf..af19df87 100644
--- a/zen/file_access.cpp
+++ b/zen/file_access.cpp
@@ -273,6 +273,18 @@ void zen::removeDirectoryPlainRecursion(const Zstring& dirPath) //throw FileErro
namespace
{
+std::wstring generateMoveErrorMsg(const Zstring& pathFrom, const Zstring& pathTo)
+{
+ if (getParentFolderPath(pathFrom) == getParentFolderPath(pathTo)) //pure "rename"
+ return replaceCpy(replaceCpy(_("Cannot rename %x to %y."),
+ L"%x", fmtPath(pathFrom)),
+ L"%y", fmtPath(getItemName(pathTo)));
+ else //"move" or "move + rename"
+ return trimCpy(replaceCpy(replaceCpy(_("Cannot move %x to %y."),
+ L"%x", L'\n' + fmtPath(pathFrom)),
+ L"%y", L'\n' + fmtPath(pathTo)));
+}
+
/* Usage overview: (avoid circular pattern!)
moveAndRenameItem() --> moveAndRenameFileSub()
@@ -283,7 +295,7 @@ namespace
//wrapper for file system rename function:
void moveAndRenameFileSub(const Zstring& pathFrom, const Zstring& pathTo, bool replaceExisting) //throw FileError, ErrorMoveUnsupported, ErrorTargetExisting
{
- auto getErrorMsg = [&] { return replaceCpy(replaceCpy(_("Cannot move file %x to %y."), L"%x", L'\n' + fmtPath(pathFrom)), L"%y", L'\n' + fmtPath(pathTo)); };
+ auto getErrorMsg = [&] { return generateMoveErrorMsg(pathFrom, pathTo); };
//rename() will never fail with EEXIST, but always (atomically) overwrite!
//=> equivalent to SetFileInformationByHandle() + FILE_RENAME_INFO::ReplaceIfExists or ::MoveFileEx() + MOVEFILE_REPLACE_EXISTING
@@ -338,6 +350,8 @@ void zen::moveAndRenameItem(const Zstring& pathFrom, const Zstring& pathTo, bool
}
+
+
namespace
{
void setWriteTimeNative(const Zstring& itemPath, const timespec& modTime, ProcSymlink procSl) //throw FileError
@@ -714,10 +728,7 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target
macOS: https://freefilesync.org/forum/viewtopic.php?t=356 */
setWriteTimeNative(targetFile, sourceInfo.st_mtim, ProcSymlink::follow); //throw FileError
}
- catch (const FileError& e)
- {
- errorModTime = FileError(e.toString()); //avoid slicing
- }
+ catch (const FileError& e) { errorModTime = e; /*might slice derived class?*/ }
return
{
diff --git a/zen/http.cpp b/zen/http.cpp
index 8cdcd65c..fcf69fb3 100644
--- a/zen/http.cpp
+++ b/zen/http.cpp
@@ -265,7 +265,17 @@ std::unique_ptr<HttpInputStream::Impl> sendHttpRequestImpl(const Zstring& url,
else
{
if (httpStatus != 200) //HTTP_STATUS_OK
- throw SysError(formatHttpError(httpStatus)); //e.g. "HTTP status 404: Not found."
+ {
+#if 0 //beneficial to add error details?
+ std::wstring errorDetails;
+ try
+ {
+ errorDetails = utfTo<std::wstring>(HttpInputStream(std::move(response)).readAll(nullptr /*notifyUnbufferedIO*/)); //throw SysError
+ }
+ catch (const SysError& e) { errorDetails = e.toString(); }
+#endif
+ throw SysError(formatHttpError(httpStatus) /*+ L' ' + errorDetails*/); //e.g. "HTTP status 404: Not found."
+ }
return response;
}
diff --git a/zen/zstring.h b/zen/zstring.h
index 5bcc8b34..bf7ac526 100644
--- a/zen/zstring.h
+++ b/zen/zstring.h
@@ -84,9 +84,11 @@ const wchar_t EM_DASH = L'\u2014';
const wchar_t* const SPACED_DASH = L" \u2014 "; //using 'EM DASH'
const wchar_t* const ELLIPSIS = L"\u2026"; //"..."
const wchar_t MULT_SIGN = L'\u00D7'; //fancy "x"
-//const wchar_t NOBREAK_SPACE = L'\u00A0';
+const wchar_t NOBREAK_SPACE = L'\u00A0';
const wchar_t ZERO_WIDTH_SPACE = L'\u200B';
+const wchar_t EN_SPACE = L'\u2002';
+
const wchar_t LTR_MARK = L'\u200E'; //UTF-8: E2 80 8E
const wchar_t RTL_MARK = L'\u200F'; //UTF-8: E2 80 8F https://www.w3.org/International/questions/qa-bidi-unicode-controls
//const wchar_t BIDI_DIR_ISOLATE_RTL = L'\u2067'; //=> not working on Win 10
@@ -94,6 +96,8 @@ const wchar_t RTL_MARK = L'\u200F'; //UTF-8: E2 80 8F https://www.w3.org/Interna
//const wchar_t BIDI_DIR_EMBEDDING_RTL = L'\u202B'; //=> not working on Win 10
//const wchar_t BIDI_POP_DIR_FORMATTING = L'\u202C'; //=> not working on Win 10
+const wchar_t RIGHT_ARROW_CURV_DOWN = L'\u2935'; //Right Arrow Curving Down
+
const wchar_t* const TAB_SPACE = L" "; //4: the only sensible space count for tabs
#endif //ZSTRING_H_73425873425789
bgstack15