summaryrefslogtreecommitdiff
path: root/zen/file_access.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zen/file_access.cpp')
-rw-r--r--zen/file_access.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/zen/file_access.cpp b/zen/file_access.cpp
index d093d7ff..009d60b2 100644
--- a/zen/file_access.cpp
+++ b/zen/file_access.cpp
@@ -1279,7 +1279,7 @@ void copyItemPermissions(const Zstring& sourcePath, const Zstring& targetPath, P
if (procSl == ProcSymlink::DIRECT)
flags |= COPYFILE_NOFOLLOW;
- if (::copyfile(sourcePath.c_str(), targetPath.c_str(), 0, flags) != 0)
+ if (::copyfile(sourcePath.c_str(), targetPath.c_str(), nullptr, flags) != 0)
THROW_LAST_FILE_ERROR(replaceCpy(replaceCpy(_("Cannot copy permissions from %x to %y."), L"%x", L"\n" + fmtPath(sourcePath)), L"%y", L"\n" + fmtPath(targetPath)), L"copyfile");
//owner is *not* copied with ::copyfile():
@@ -1498,7 +1498,7 @@ void zen::copyNewDirectory(const Zstring& sourcePath, const Zstring& targetPath,
}
#elif defined ZEN_MAC
- /*int rv =*/ ::copyfile(sourcePath.c_str(), targetPath.c_str(), 0, COPYFILE_XATTR);
+ /*int rv =*/ ::copyfile(sourcePath.c_str(), targetPath.c_str(), nullptr, COPYFILE_XATTR);
#endif
ZEN_ON_SCOPE_FAIL(try { removeDirectorySimple(targetPath); }
@@ -1578,7 +1578,7 @@ void zen::copySymlink(const Zstring& sourceLink, const Zstring& targetLink, bool
if (::lstat(sourceLink.c_str(), &sourceInfo) != 0)
THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot read file attributes of %x."), L"%x", fmtPath(sourceLink)), L"lstat");
- if (::copyfile(sourceLink.c_str(), targetLink.c_str(), 0, COPYFILE_XATTR | COPYFILE_NOFOLLOW) != 0)
+ if (::copyfile(sourceLink.c_str(), targetLink.c_str(), nullptr, COPYFILE_XATTR | COPYFILE_NOFOLLOW) != 0)
THROW_LAST_FILE_ERROR(replaceCpy(replaceCpy(_("Cannot copy attributes from %x to %y."), L"%x", L"\n" + fmtPath(sourceLink)), L"%y", L"\n" + fmtPath(targetLink)), L"copyfile");
setFileTimeRaw(targetLink, &sourceInfo.st_birthtimespec, sourceInfo.st_mtimespec, ProcSymlink::DIRECT); //throw FileError
@@ -2284,8 +2284,15 @@ InSyncAttributes copyFileOsSpecific(const Zstring& sourceFile, //throw FileError
//http://blog.plasticsfuture.org/2006/03/05/the-state-of-backup-and-cloning-tools-under-mac-os-x/
//docs: http://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/copyfile.3.html
//source: http://www.opensource.apple.com/source/copyfile/copyfile-103.92.1/copyfile.c
- if (::fcopyfile(fileIn.getHandle(), fileOut.getHandle(), 0, COPYFILE_XATTR) != 0)
- THROW_LAST_FILE_ERROR(replaceCpy(replaceCpy(_("Cannot copy attributes from %x to %y."), L"%x", L"\n" + fmtPath(sourceFile)), L"%y", L"\n" + fmtPath(targetFile)), L"copyfile");
+ if (::fcopyfile(fileIn.getHandle(), fileOut.getHandle(), nullptr, COPYFILE_XATTR) != 0)
+ {
+ /*
+ extended attributes are only optional here => ignore error
+ E2BIG - reference email: "FFS V7.8 on Mac with 10.11.2 ElCapitan"
+ EINVAL - reference email: "Error Code 22: Invalid argument (copyfile)"
+ */
+ //THROW_LAST_FILE_ERROR(replaceCpy(replaceCpy(_("Cannot copy attributes from %x to %y."), L"%x", L"\n" + fmtPath(sourceFile)), L"%y", L"\n" + fmtPath(targetFile)), L"fcopyfile");
+ }
#endif
fileOut.close(); //throw FileError -> optional, but good place to catch errors when closing stream!
@@ -2309,10 +2316,10 @@ InSyncAttributes copyFileOsSpecific(const Zstring& sourceFile, //throw FileError
#endif
/*
- ------------------
- |File Copy Layers|
- ------------------
- copyNewFile
+ ------------------
+ |File Copy Layers|
+ ------------------
+ copyNewFile
|
copyFileOsSpecific (solve 8.3 issue on Windows)
|
bgstack15