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

Side by Side Diff: runtime/bin/directory_android.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.cc ('k') | runtime/bin/directory_linux.cc » ('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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 9
10 #include <dirent.h> // NOLINT 10 #include <dirent.h> // NOLINT
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 char buffer[PATH_MAX]; 423 char buffer[PATH_MAX];
424 if (NULL == getcwd(buffer, PATH_MAX)) { 424 if (NULL == getcwd(buffer, PATH_MAX)) {
425 return NULL; 425 return NULL;
426 } 426 }
427 427
428 return strdup(buffer); 428 return strdup(buffer);
429 } 429 }
430 430
431 431
432 bool Directory::SetCurrent(const char* path) {
433 int result = TEMP_FAILURE_RETRY(chdir(path));
434 return result == 0;
435 }
436
437
432 bool Directory::Create(const char* dir_name) { 438 bool Directory::Create(const char* dir_name) {
433 // Create the directory with the permissions specified by the 439 // Create the directory with the permissions specified by the
434 // process umask. 440 // process umask.
435 int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777)); 441 int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777));
436 // If the directory already exists, treat it as a success. 442 // If the directory already exists, treat it as a success.
437 if (result == -1 && errno == EEXIST) { 443 if (result == -1 && errno == EEXIST) {
438 return (Exists(dir_name) == EXISTS); 444 return (Exists(dir_name) == EXISTS);
439 } 445 }
440 return (result == 0); 446 return (result == 0);
441 } 447 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 bool Directory::Rename(const char* path, const char* new_path) { 522 bool Directory::Rename(const char* path, const char* new_path) {
517 ExistsResult exists = Exists(path); 523 ExistsResult exists = Exists(path);
518 if (exists != EXISTS) return false; 524 if (exists != EXISTS) return false;
519 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); 525 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0);
520 } 526 }
521 527
522 } // namespace bin 528 } // namespace bin
523 } // namespace dart 529 } // namespace dart
524 530
525 #endif // defined(TARGET_OS_ANDROID) 531 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/directory.cc ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698