summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/Path.inc
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2019-04-24 19:08:43 +0000
committerAdrian Prantl <aprantl@apple.com>2019-04-24 19:08:43 +0000
commitc90ff5e123c5d759697b866a75594d465a8a0591 (patch)
treefe52558d74d3d2f592ee224a78d619b2489a0276 /llvm/lib/Support/Unix/Path.inc
parent91cee68e1f0fe3aa22513af6fa6d7308150bcfc9 (diff)
downloadbcm5719-llvm-c90ff5e123c5d759697b866a75594d465a8a0591.tar.gz
bcm5719-llvm-c90ff5e123c5d759697b866a75594d465a8a0591.zip
Revert using fcopyfile(3) to implement sys::fs::copy_file(Twine, int) on macOS
It turns out that I mesread the man page and fcopyfile(3) does not actually support COPYFILE_CLONE for files. <rdar://problem/50148757> llvm-svn: 359127
Diffstat (limited to 'llvm/lib/Support/Unix/Path.inc')
-rw-r--r--llvm/lib/Support/Unix/Path.inc24
1 files changed, 4 insertions, 20 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index fbe3ed11c59..0e150d1ac26 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -1119,6 +1119,9 @@ namespace fs {
#ifdef __APPLE__
/// This implementation tries to perform an APFS CoW clone of the file,
/// which can be much faster and uses less space.
+/// Unfortunately fcopyfile(3) does not support COPYFILE_CLONE, so the
+/// file descriptor variant of this function still uses the default
+/// implementation.
std::error_code copy_file(const Twine &From, const Twine &To) {
uint32_t Flag = COPYFILE_DATA;
if (__builtin_available(macos 10.12, *)) {
@@ -1138,26 +1141,7 @@ std::error_code copy_file(const Twine &From, const Twine &To) {
return std::error_code();
return std::error_code(errno, std::generic_category());
}
-
-/// This implementation tries to perform an APFS CoW clone of the file,
-/// which can be much faster and uses less space.
-std::error_code copy_file(const Twine &From, int ToFD) {
- int ReadFD;
- if (std::error_code EC = openFileForRead(From, ReadFD, OF_None))
- return EC;
-
- uint32_t Flag = COPYFILE_DATA;
- if (__builtin_available(macos 10.12, *))
- Flag = COPYFILE_CLONE;
-
- int Status = fcopyfile(ReadFD, ToFD, /*State*/ NULL, Flag);
-
- close(ReadFD);
- if (Status == 0)
- return std::error_code();
- return std::error_code(errno, std::generic_category());
-}
-#endif
+#endif // __APPLE__
} // end namespace fs
OpenPOWER on IntegriCloud