Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: runtime/bin/file_macos.cc

Issue 105133004: Add File.copy(Sync) to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/file_macos.cc
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index 46c77cb40c86cc8147d82c6b302eacf79f971a2c..371809743d035d872cfd2ebf484864eaeb98c0ad 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_DATA) == 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) {

Powered by Google App Engine
This is Rietveld 408576698