diff options
author | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:32:47 +0100 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2016-03-16 21:32:47 +0100 |
commit | f7baa4de2ea9e5ce945078b76a3f20244a5d7946 (patch) | |
tree | 744a305661052e368a51b0063e16155dc9f7fe6e /zen/file_access.cpp | |
parent | 7.7 (diff) | |
download | FreeFileSync-f7baa4de2ea9e5ce945078b76a3f20244a5d7946.tar.gz FreeFileSync-f7baa4de2ea9e5ce945078b76a3f20244a5d7946.tar.bz2 FreeFileSync-f7baa4de2ea9e5ce945078b76a3f20244a5d7946.zip |
7.8
Diffstat (limited to 'zen/file_access.cpp')
-rw-r--r-- | zen/file_access.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/zen/file_access.cpp b/zen/file_access.cpp index a66cbc6b..d093d7ff 100644 --- a/zen/file_access.cpp +++ b/zen/file_access.cpp @@ -232,6 +232,7 @@ std::uint64_t zen::getFreeDiskSpace(const Zstring& path) //throw FileError, retu nullptr, //__out_opt PULARGE_INTEGER lpTotalNumberOfBytes, nullptr)) //__out_opt PULARGE_INTEGER lpTotalNumberOfFreeBytes THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot determine free disk space for %x."), L"%x", fmtPath(path)), L"GetDiskFreeSpaceEx"); + //succeeds even if path is not yet existing! //return 0 if info is not available: "The GetDiskFreeSpaceEx function returns zero for lpFreeBytesAvailable for all CD requests" return get64BitUInt(bytesFree.LowPart, bytesFree.HighPart); @@ -2233,9 +2234,11 @@ InSyncAttributes copyFileOsSpecific(const Zstring& sourceFile, //throw FileError struct ::stat sourceInfo = {}; if (::fstat(fileIn.getHandle(), &sourceInfo) != 0) THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot read file attributes of %x."), L"%x", fmtPath(sourceFile)), L"fstat"); - - const int fdTarget = ::open(targetFile.c_str(), O_WRONLY | O_CREAT | O_EXCL, - sourceInfo.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)); //analog to "cp" which copies "mode" (considering umask) by default + + const mode_t mode = sourceInfo.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); //analog to "cp" which copies "mode" (considering umask) by default + //it seems we don't need S_IWUSR, not even for the setFileTime() below! (tested with source file having different user/group!) + + const int fdTarget = ::open(targetFile.c_str(), O_WRONLY | O_CREAT | O_EXCL, mode); //=> need copyItemPermissions() only for "chown" and umask-agnostic permissions if (fdTarget == -1) { |