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

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

Issue 1800863002: Cleanup in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.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_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 ASSERT((errno == ELOOP) || 359 ASSERT((errno == ELOOP) ||
360 (errno == ENAMETOOLONG) || 360 (errno == ENAMETOOLONG) ||
361 (errno == ENOENT) || 361 (errno == ENOENT) ||
362 (errno == ENOTDIR)); 362 (errno == ENOTDIR));
363 return DOES_NOT_EXIST; 363 return DOES_NOT_EXIST;
364 } 364 }
365 } 365 }
366 366
367 367
368 char* Directory::CurrentNoScope() { 368 char* Directory::CurrentNoScope() {
369 char buffer[PATH_MAX]; 369 return getcwd(NULL, 0);
370 if (getcwd(buffer, PATH_MAX) == NULL) {
371 return NULL;
372 }
373 return strdup(buffer);
374 } 370 }
375 371
376 372
377 const char* Directory::Current() { 373 const char* Directory::Current() {
378 char buffer[PATH_MAX]; 374 char buffer[PATH_MAX];
379 if (getcwd(buffer, PATH_MAX) == NULL) { 375 if (getcwd(buffer, PATH_MAX) == NULL) {
380 return NULL; 376 return NULL;
381 } 377 }
382 return DartUtils::ScopedCopyCString(buffer); 378 return DartUtils::ScopedCopyCString(buffer);
383 } 379 }
384 380
385 381
386 bool Directory::SetCurrent(const char* path) { 382 bool Directory::SetCurrent(const char* path) {
387 return NO_RETRY_EXPECTED(chdir(path)) == 0; 383 return (NO_RETRY_EXPECTED(chdir(path)) == 0);
388 } 384 }
389 385
390 386
391 bool Directory::Create(const char* dir_name) { 387 bool Directory::Create(const char* dir_name) {
392 // Create the directory with the permissions specified by the 388 // Create the directory with the permissions specified by the
393 // process umask. 389 // process umask.
394 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777)); 390 int result = NO_RETRY_EXPECTED(mkdir(dir_name, 0777));
395 // If the directory already exists, treat it as a success. 391 // If the directory already exists, treat it as a success.
396 if ((result == -1) && (errno == EEXIST)) { 392 if ((result == -1) && (errno == EEXIST)) {
397 return (Exists(dir_name) == EXISTS); 393 return (Exists(dir_name) == EXISTS);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 return DeleteRecursively(&path); 458 return DeleteRecursively(&path);
463 } 459 }
464 } 460 }
465 461
466 462
467 bool Directory::Rename(const char* path, const char* new_path) { 463 bool Directory::Rename(const char* path, const char* new_path) {
468 ExistsResult exists = Exists(path); 464 ExistsResult exists = Exists(path);
469 if (exists != EXISTS) { 465 if (exists != EXISTS) {
470 return false; 466 return false;
471 } 467 }
472 return NO_RETRY_EXPECTED(rename(path, new_path)) == 0; 468 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
473 } 469 }
474 470
475 } // namespace bin 471 } // namespace bin
476 } // namespace dart 472 } // namespace dart
477 473
478 #endif // defined(TARGET_OS_LINUX) 474 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698