From d30e0825ff61e9d8bae68cdfd2798da0badcf255 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sat, 28 Oct 2023 08:29:29 -0400 Subject: add upstream 13.1 --- zen/dir_watcher.h | 1 - zen/file_access.cpp | 22 +++++++++++----------- zen/format_unit.h | 2 -- zen/legacy_compiler.h | 5 +---- zen/serialize.h | 11 +---------- zen/thread.h | 1 + 6 files changed, 14 insertions(+), 28 deletions(-) (limited to 'zen') diff --git a/zen/dir_watcher.h b/zen/dir_watcher.h index a4a061e8..24af9810 100644 --- a/zen/dir_watcher.h +++ b/zen/dir_watcher.h @@ -8,7 +8,6 @@ #define DIR_WATCHER_348577025748023458 #include -//#include #include #include #include "file_error.h" diff --git a/zen/file_access.cpp b/zen/file_access.cpp index af19df87..6a8a36da 100644 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -273,16 +273,16 @@ void zen::removeDirectoryPlainRecursion(const Zstring& dirPath) //throw FileErro namespace { -std::wstring generateMoveErrorMsg(const Zstring& pathFrom, const Zstring& pathTo) +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))); + 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!) @@ -732,11 +732,11 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target return { - .fileSize = makeUnsigned(sourceInfo.st_size), + .fileSize = makeUnsigned(sourceInfo.st_size), .sourceModTime = sourceInfo.st_mtim, .sourceFileIdx = sourceInfo.st_ino, .targetFileIdx = targetFileIdx, - .errorModTime = errorModTime, + .errorModTime = errorModTime, }; } diff --git a/zen/format_unit.h b/zen/format_unit.h index 5498e8c2..d7321a97 100644 --- a/zen/format_unit.h +++ b/zen/format_unit.h @@ -9,8 +9,6 @@ #include #include -//#include -//#include "string_tools.h" namespace zen diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h index c853b139..fce7fd7d 100644 --- a/zen/legacy_compiler.h +++ b/zen/legacy_compiler.h @@ -32,7 +32,7 @@ namespace std //W(hy)TF is this not standard? https://stackoverflow.com/a/47735624 template inline basic_string operator+(basic_string&& lhs, const basic_string_view rhs) -{ return move(lhs.append(rhs.begin(), rhs.end())); } //the move *is* needed!!! +{ return std::move(lhs.append(rhs.begin(), rhs.end())); } //the move *is* needed!!! //template inline //basic_string operator+(const basic_string& lhs, const basic_string_view& rhs) { return basic_string(lhs) + rhs; } @@ -40,9 +40,6 @@ basic_string operator+(basic_string&& } //--------------------------------------------------------------------------------- -//support for std::string::resize_and_overwrite() - #define ZEN_HAVE_RESIZE_AND_OVERWRITE 1 - namespace zen { double fromChars(const char* first, const char* last); diff --git a/zen/serialize.h b/zen/serialize.h index 02dcd2b2..f3e4f7ff 100644 --- a/zen/serialize.h +++ b/zen/serialize.h @@ -7,7 +7,6 @@ #ifndef SERIALIZE_H_839405783574356 #define SERIALIZE_H_839405783574356 -//#include #include #include "sys_error.h" //keep header clean from specific stream implementations! (e.g.file_io.h)! used by abstract.h! @@ -261,21 +260,13 @@ BinContainer unbufferedLoad(Function tryRead /*(void* buffer, size_t bytesToRead BinContainer buf; for (;;) { -#ifndef ZEN_HAVE_RESIZE_AND_OVERWRITE -#error include legacy_compiler.h! -#endif -#if ZEN_HAVE_RESIZE_AND_OVERWRITE //permature(?) perf optimization; avoid needless zero-initialization: size_t bytesRead = 0; buf.resize_and_overwrite(buf.size() + blockSize, [&, bufSizeOld = buf.size()](char* rawBuf, size_t /*rawBufSize: caveat: may be larger than what's requested*/) + //permature(?) perf optimization; avoid needless zero-initialization: { bytesRead = tryRead(rawBuf + bufSizeOld, blockSize); //throw X; may return short; only 0 means EOF return bufSizeOld + bytesRead; }); -#else - buf.resize(buf.size() + blockSize); //needless zero-initialization! - const size_t bytesRead = tryRead(buf.data() + buf.size() - blockSize, blockSize); //throw X; may return short; only 0 means EOF - buf.resize(buf.size() - blockSize + bytesRead); //caveat: unsigned arithmetics -#endif if (bytesRead == 0) //end of file { //caveat: memory consumption of returned string! diff --git a/zen/thread.h b/zen/thread.h index 2464f8be..27b4c9b8 100644 --- a/zen/thread.h +++ b/zen/thread.h @@ -9,6 +9,7 @@ #include #include +#include #include "ring_buffer.h" #include "zstring.h" -- cgit