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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/directory_posix.cc ('k') | tests/standalone/io/directory_error_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/directory.h" 5 #include "bin/directory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "bin/platform.h" 10 #include "bin/platform.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 375 }
376 376
377 377
378 bool Directory::Delete(const char* dir_name, bool recursive) { 378 bool Directory::Delete(const char* dir_name, bool recursive) {
379 if (!recursive) { 379 if (!recursive) {
380 return (RemoveDirectory(dir_name) != 0); 380 return (RemoveDirectory(dir_name) != 0);
381 } else { 381 } else {
382 return DeleteRecursively(dir_name); 382 return DeleteRecursively(dir_name);
383 } 383 }
384 } 384 }
385
386
387 bool Directory::Rename(const char* path, const char* new_path) {
388 ExistsResult exists = Exists(path);
389 if (exists != EXISTS) return false;
390 ExistsResult new_exists = Exists(new_path);
391 // MoveFile does not allow replacing exising directories. Therefore,
392 // if the new_path is currently a directory we need to delete it
393 // first.
394 if (new_exists == EXISTS) {
395 bool success = DeleteRecursively(new_path);
396 if (!success) return false;
397 }
398 DWORD flags = MOVEFILE_WRITE_THROUGH;
399 return (MoveFileEx(path, new_path, flags) != 0);
400 }
OLDNEW
« 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