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

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

Issue 1800863002: Cleanup in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Windows fixes Created 4 years, 9 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
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 ASSERT((errno == ELOOP) || 357 ASSERT((errno == ELOOP) ||
358 (errno == ENAMETOOLONG) || 358 (errno == ENAMETOOLONG) ||
359 (errno == ENOENT) || 359 (errno == ENOENT) ||
360 (errno == ENOTDIR)); 360 (errno == ENOTDIR));
361 return DOES_NOT_EXIST; 361 return DOES_NOT_EXIST;
362 } 362 }
363 } 363 }
364 364
365 365
366 char* Directory::CurrentNoScope() { 366 char* Directory::CurrentNoScope() {
367 return getcwd(NULL, 0); 367 char buffer[PATH_MAX];
zra 2016/03/15 18:12:29 Changed to match other platforms.
Ivan Posva 2016/03/16 07:33:51 It looks like the original was working correctly w
zra 2016/03/16 17:00:13 I checked the Linux docs. getcwd(NULL, 0) works th
368 if (getcwd(buffer, PATH_MAX) == NULL) {
369 return NULL;
370 }
371 return strdup(buffer);
368 } 372 }
369 373
370 374
371 const char* Directory::Current() { 375 const char* Directory::Current() {
372 char* result = DartUtils::ScopedCString(PATH_MAX); 376 char buffer[PATH_MAX];
373 ASSERT(result != NULL); 377 if (getcwd(buffer, PATH_MAX) == NULL) {
zra 2016/03/15 18:12:29 Ported fix from Linux.
374 return getcwd(result, PATH_MAX); 378 return NULL;
379 }
380 return DartUtils::ScopedCopyCString(buffer);
375 } 381 }
376 382
377 383
378 bool Directory::SetCurrent(const char* path) { 384 bool Directory::SetCurrent(const char* path) {
379 int result = NO_RETRY_EXPECTED(chdir(path)); 385 int result = NO_RETRY_EXPECTED(chdir(path));
380 return result == 0; 386 return (result == 0);
381 } 387 }
382 388
383 389
384 bool Directory::Create(const char* dir_name) { 390 bool Directory::Create(const char* dir_name) {
385 // Create the directory with the permissions specified by the 391 // Create the directory with the permissions specified by the
386 // process umask. 392 // process umask.
387 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777)); 393 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777));
388 // If the directory already exists, treat it as a success. 394 // If the directory already exists, treat it as a success.
389 if ((result == -1) && (errno == EEXIST)) { 395 if ((result == -1) && (errno == EEXIST)) {
390 return (Exists(dir_name) == EXISTS); 396 return (Exists(dir_name) == EXISTS);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (exists != EXISTS) { 467 if (exists != EXISTS) {
462 return false; 468 return false;
463 } 469 }
464 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); 470 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
465 } 471 }
466 472
467 } // namespace bin 473 } // namespace bin
468 } // namespace dart 474 } // namespace dart
469 475
470 #endif // defined(TARGET_OS_MACOS) 476 #endif // defined(TARGET_OS_MACOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698