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

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

Issue 23702037: Fix error handling when current working directory is deleted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix type of _Directory._current Created 7 years, 3 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') | sdk/lib/_internal/lib/io_patch.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 #include "bin/utils.h" 10 #include "bin/utils.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 Directory::ExistsResult Directory::Exists(const char* dir_name) { 344 Directory::ExistsResult Directory::Exists(const char* dir_name) {
345 const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name); 345 const wchar_t* system_name = StringUtils::Utf8ToWide(dir_name);
346 Directory::ExistsResult result = ExistsHelper(system_name); 346 Directory::ExistsResult result = ExistsHelper(system_name);
347 free(const_cast<wchar_t*>(system_name)); 347 free(const_cast<wchar_t*>(system_name));
348 return result; 348 return result;
349 } 349 }
350 350
351 351
352 char* Directory::Current() { 352 char* Directory::Current() {
353 int length = GetCurrentDirectoryW(0, NULL); 353 int length = GetCurrentDirectoryW(0, NULL);
354 if (length == 0) return NULL;
354 wchar_t* current = new wchar_t[length + 1]; 355 wchar_t* current = new wchar_t[length + 1];
355 GetCurrentDirectoryW(length + 1, current); 356 GetCurrentDirectoryW(length + 1, current);
356 char* result = StringUtils::WideToUtf8(current); 357 char* result = StringUtils::WideToUtf8(current);
357 delete[] current; 358 delete[] current;
358 return result; 359 return result;
359 } 360 }
360 361
361 362
362 bool Directory::SetCurrent(const char* path) { 363 bool Directory::SetCurrent(const char* path) {
363 const wchar_t* system_path = StringUtils::Utf8ToWide(path); 364 const wchar_t* system_path = StringUtils::Utf8ToWide(path);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 MoveFileExW(system_path, system_new_path, flags); 469 MoveFileExW(system_path, system_new_path, flags);
469 free(const_cast<wchar_t*>(system_path)); 470 free(const_cast<wchar_t*>(system_path));
470 free(const_cast<wchar_t*>(system_new_path)); 471 free(const_cast<wchar_t*>(system_new_path));
471 return (move_status != 0); 472 return (move_status != 0);
472 } 473 }
473 474
474 } // namespace bin 475 } // namespace bin
475 } // namespace dart 476 } // namespace dart
476 477
477 #endif // defined(TARGET_OS_WINDOWS) 478 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/directory_patch.dart ('k') | sdk/lib/_internal/lib/io_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698