Index: runtime/bin/file_macos.cc |
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc |
index 46c77cb40c86cc8147d82c6b302eacf79f971a2c..b9500a74fee98e52df71be2d6e15badbd5ea72a7 100644 |
--- a/runtime/bin/file_macos.cc |
+++ b/runtime/bin/file_macos.cc |
@@ -9,6 +9,7 @@ |
#include <errno.h> // NOLINT |
#include <fcntl.h> // NOLINT |
+#include <copyfile.h> // NOLINT |
#include <sys/stat.h> // NOLINT |
#include <unistd.h> // NOLINT |
#include <libgen.h> // NOLINT |
@@ -221,6 +222,19 @@ bool File::RenameLink(const char* old_path, const char* new_path) { |
} |
+bool File::Copy(const char* old_path, const char* new_path) { |
+ File::Type type = File::GetType(old_path, true); |
+ if (type == kIsFile) { |
+ return copyfile(old_path, new_path, NULL, COPYFILE_ALL) == 0; |
+ } else if (type == kIsDirectory) { |
+ errno = EISDIR; |
+ } else { |
+ errno = ENOENT; |
+ } |
+ return false; |
+} |
+ |
+ |
off64_t File::LengthFromPath(const char* name) { |
struct stat st; |
if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |