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

Unified Diff: runtime/bin/directory_win.cc

Issue 10414046: Add support for directory renaming to dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 8 years, 7 months 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/directory_posix.cc ('k') | tests/standalone/io/directory_error_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_win.cc
diff --git a/runtime/bin/directory_win.cc b/runtime/bin/directory_win.cc
index 0fb1e1e245e3e29691162a3eb6bdad01831a9693..7fedd6c0bc9c29acd0c76219b1ced13c475c965f 100644
--- a/runtime/bin/directory_win.cc
+++ b/runtime/bin/directory_win.cc
@@ -382,3 +382,19 @@ bool Directory::Delete(const char* dir_name, bool recursive) {
return DeleteRecursively(dir_name);
}
}
+
+
+bool Directory::Rename(const char* path, const char* new_path) {
+ ExistsResult exists = Exists(path);
+ if (exists != EXISTS) return false;
+ ExistsResult new_exists = Exists(new_path);
+ // MoveFile does not allow replacing exising directories. Therefore,
+ // if the new_path is currently a directory we need to delete it
+ // first.
+ if (new_exists == EXISTS) {
+ bool success = DeleteRecursively(new_path);
+ if (!success) return false;
+ }
+ DWORD flags = MOVEFILE_WRITE_THROUGH;
+ return (MoveFileEx(path, new_path, flags) != 0);
+}
« no previous file with comments | « runtime/bin/directory_posix.cc ('k') | tests/standalone/io/directory_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698