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

Side by Side Diff: runtime/bin/directory_win.cc

Issue 13896034: Add the ability to change the working directory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tests Created 7 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_patch.dart ('k') | samples/build_dart/build.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 "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/directory.h" 8 #include "bin/directory.h"
9 #include "bin/file.h" 9 #include "bin/file.h"
10 10
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 char* Directory::Current() { 418 char* Directory::Current() {
419 int length = GetCurrentDirectoryW(0, NULL); 419 int length = GetCurrentDirectoryW(0, NULL);
420 wchar_t* current = new wchar_t[length + 1]; 420 wchar_t* current = new wchar_t[length + 1];
421 GetCurrentDirectoryW(length + 1, current); 421 GetCurrentDirectoryW(length + 1, current);
422 char* result = StringUtils::WideToUtf8(current); 422 char* result = StringUtils::WideToUtf8(current);
423 delete[] current; 423 delete[] current;
424 return result; 424 return result;
425 } 425 }
426 426
427 427
428 bool Directory::SetCurrent(const char* path) {
429 const wchar_t* system_path = StringUtils::Utf8ToWide(path);
430 bool result = SetCurrentDirectoryW(system_path) != 0;
431 free(const_cast<wchar_t*>(system_path));
432 return result;
433 }
434
435
428 bool Directory::Create(const char* dir_name) { 436 bool Directory::Create(const char* dir_name) {
429 const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name); 437 const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name);
430 int create_status = CreateDirectoryW(system_name, NULL); 438 int create_status = CreateDirectoryW(system_name, NULL);
431 // If the directory already existed, treat it as a success. 439 // If the directory already existed, treat it as a success.
432 if (create_status == 0 && 440 if (create_status == 0 &&
433 GetLastError() == ERROR_ALREADY_EXISTS && 441 GetLastError() == ERROR_ALREADY_EXISTS &&
434 ExistsHelper(system_name) == EXISTS) { 442 ExistsHelper(system_name) == EXISTS) {
435 free(const_cast<wchar_t*>(system_name)); 443 free(const_cast<wchar_t*>(system_name));
436 return true; 444 return true;
437 } 445 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 MoveFileExW(system_path, system_new_path, flags); 534 MoveFileExW(system_path, system_new_path, flags);
527 free(const_cast<wchar_t*>(system_path)); 535 free(const_cast<wchar_t*>(system_path));
528 free(const_cast<wchar_t*>(system_new_path)); 536 free(const_cast<wchar_t*>(system_new_path));
529 return (move_status != 0); 537 return (move_status != 0);
530 } 538 }
531 539
532 } // namespace bin 540 } // namespace bin
533 } // namespace dart 541 } // namespace dart
534 542
535 #endif // defined(TARGET_OS_WINDOWS) 543 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/directory_patch.dart ('k') | samples/build_dart/build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698