diff options
author | B. Stack <bgstack15@gmail.com> | 2023-06-20 07:46:53 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-06-20 07:46:53 -0400 |
commit | f76994f1fb3e25c4563c9d8afce6bbc86701d1d2 (patch) | |
tree | b39389163603195a0169af57712eb0765e5c11f4 /zen/file_access.cpp | |
parent | add upstream 12.3 (diff) | |
download | FreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.tar.gz FreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.tar.bz2 FreeFileSync-f76994f1fb3e25c4563c9d8afce6bbc86701d1d2.zip |
add upstream 12.412.4
Diffstat (limited to 'zen/file_access.cpp')
-rw-r--r-- | zen/file_access.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/zen/file_access.cpp b/zen/file_access.cpp index 24e418c9..6c47936c 100644 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -64,7 +64,7 @@ std::variant<ItemType, Zstring /*last existing parent path*/> getItemTypeIfExist } catch (const SysErrorCode& e) //let's dig deeper, but *only* if error code sounds like "not existing" { - const std::optional<Zstring> parentPath = getParentFolderPath(itemPath); + const std::optional<Zstring>& parentPath = getParentFolderPath(itemPath); if (!parentPath) //device root => quick access test throw; if (e.errorCode == ENOENT) @@ -178,8 +178,6 @@ uint64_t zen::getFileSize(const Zstring& filePath) //throw FileError } - - Zstring zen::getTempFolderPath() //throw FileError { if (const std::optional<Zstring> tempDirPath = getEnvironmentVar("TMPDIR")) @@ -561,7 +559,7 @@ void zen::createDirectoryIfMissingRecursion(const Zstring& dirPath) //throw File } catch (FileError&) //not yet existing or access error { - const std::optional<Zstring> parentPath = getParentFolderPath(dirPathEx); + const std::optional<Zstring>& parentPath = getParentFolderPath(dirPathEx); if (!parentPath)//device root => quick access test throw; dirNames.push_front(getItemName(dirPathEx)); @@ -667,7 +665,7 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target } FileOutputPlain fileOut(fdTarget, targetFile); //pass ownership - //preallocate disk space + reduce fragmentation (perf: no real benefit) + //preallocate disk space + reduce fragmentation fileOut.reserveSpace(sourceInfo.st_size); //throw FileError unbufferedStreamCopy([&](void* buffer, size_t bytesToRead) @@ -686,8 +684,10 @@ FileCopyResult zen::copyNewFile(const Zstring& sourceFile, const Zstring& target }, fileOut.getBlockSize() /*throw FileError*/); //throw FileError, X + //possible improvement: copy_file_range() performs an in-kernel copy: https://github.com/coreutils/coreutils/blob/17479ef60c8edbd2fe8664e31a7f69704f0cd221/src/copy.c#L342 + #if 0 - //clean file system cache: needed at all? no user complaints at all!!! + //clean file system cache: needed at all? no user complaints at all so far!!! //posix_fadvise(POSIX_FADV_DONTNEED) does nothing, unless data was already read from/written to disk: https://insights.oetiker.ch/linux/fadvise/ // => should be "most" of the data at this point => good enough? if (::posix_fadvise(fileIn.getHandle(), 0 /*offset*/, 0 /*len*/, POSIX_FADV_DONTNEED) != 0) //"len == 0" means "end of the file" |