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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_patch.dart ('k') | runtime/bin/io_service.h » ('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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 free(const_cast<wchar_t*>(system_old_path)); 315 free(const_cast<wchar_t*>(system_old_path));
316 free(const_cast<wchar_t*>(system_new_path)); 316 free(const_cast<wchar_t*>(system_new_path));
317 return (move_status != 0); 317 return (move_status != 0);
318 } else { 318 } else {
319 SetLastError(ERROR_FILE_NOT_FOUND); 319 SetLastError(ERROR_FILE_NOT_FOUND);
320 } 320 }
321 return false; 321 return false;
322 } 322 }
323 323
324 324
325 bool File::Copy(const char* old_path, const char* new_path) {
326 File::Type type = GetType(old_path, false);
327 if (type == kIsFile) {
328 const wchar_t* system_old_path = StringUtils::Utf8ToWide(old_path);
329 const wchar_t* system_new_path = StringUtils::Utf8ToWide(new_path);
330 bool success = CopyFileExW(system_old_path,
331 system_new_path,
332 NULL,
333 NULL,
334 NULL,
335 0) != 0;
336 free(const_cast<wchar_t*>(system_old_path));
337 free(const_cast<wchar_t*>(system_new_path));
338 return success;
339 } else {
340 SetLastError(ERROR_FILE_NOT_FOUND);
341 }
342 return false;
343 }
344
345
325 off64_t File::LengthFromPath(const char* name) { 346 off64_t File::LengthFromPath(const char* name) {
326 struct __stat64 st; 347 struct __stat64 st;
327 const wchar_t* system_name = StringUtils::Utf8ToWide(name); 348 const wchar_t* system_name = StringUtils::Utf8ToWide(name);
328 int stat_status = _wstat64(system_name, &st); 349 int stat_status = _wstat64(system_name, &st);
329 free(const_cast<wchar_t*>(system_name)); 350 free(const_cast<wchar_t*>(system_name));
330 if (stat_status == 0) { 351 if (stat_status == 0) {
331 return st.st_size; 352 return st.st_size;
332 } 353 }
333 return -1; 354 return -1;
334 } 355 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 return kIdentical; 627 return kIdentical;
607 } else { 628 } else {
608 return kDifferent; 629 return kDifferent;
609 } 630 }
610 } 631 }
611 632
612 } // namespace bin 633 } // namespace bin
613 } // namespace dart 634 } // namespace dart
614 635
615 #endif // defined(TARGET_OS_WINDOWS) 636 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« 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