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

Unified Diff: runtime/bin/file_win.cc

Issue 105133004: Add File.copy(Sync) to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix permissions. 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
« no previous file with comments | « runtime/bin/file_patch.dart ('k') | runtime/bin/io_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 4c3c853d5c50b60efbc9c8586d3f2ef0df91cab0..1be41cbbea81dc8aa216b4774b6a13f61113cd9a 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -322,6 +322,27 @@ 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 = GetType(old_path, false);
+ if (type == kIsFile) {
+ const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path);
+ const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path);
+ bool success = CopyFileExW(system_old_path,
+ system_new_path,
+ NULL,
+ NULL,
+ NULL,
+ 0) != 0;
+ free(const_cast<wchar_t*>(system_old_path));
+ free(const_cast<wchar_t*>(system_new_path));
+ return success;
+ } else {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ }
+ return false;
+}
+
+
off64_t File::LengthFromPath(const char* name) {
struct __stat64 st;
const wchar_t* system_name = StringUtils::Utf8ToWide(name);
« no previous file with comments | « runtime/bin/file_patch.dart ('k') | runtime/bin/io_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698