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

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

Issue 2580133002: Fix directory existence query error (Closed)
Patch Set: Use ENOTDIR. Fix test Created 4 years 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 | « no previous file | runtime/bin/directory_fuchsia.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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 344 }
345 345
346 346
347 Directory::ExistsResult Directory::Exists(const char* dir_name) { 347 Directory::ExistsResult Directory::Exists(const char* dir_name) {
348 struct stat entry_info; 348 struct stat entry_info;
349 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info)); 349 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info));
350 if (success == 0) { 350 if (success == 0) {
351 if (S_ISDIR(entry_info.st_mode)) { 351 if (S_ISDIR(entry_info.st_mode)) {
352 return EXISTS; 352 return EXISTS;
353 } else { 353 } else {
354 // An OSError may be constructed based on the return value of this
355 // function, so set errno to something that makes sense.
356 errno = ENOTDIR;
354 return DOES_NOT_EXIST; 357 return DOES_NOT_EXIST;
355 } 358 }
356 } else { 359 } else {
357 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || 360 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) ||
358 (errno == ENOMEM) || (errno == EOVERFLOW)) { 361 (errno == ENOMEM) || (errno == EOVERFLOW)) {
359 // Search permissions denied for one of the directories in the 362 // Search permissions denied for one of the directories in the
360 // path or a low level error occured. We do not know if the 363 // path or a low level error occured. We do not know if the
361 // directory exists. 364 // directory exists.
362 return UNKNOWN; 365 return UNKNOWN;
363 } 366 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 if (exists != EXISTS) { 476 if (exists != EXISTS) {
474 return false; 477 return false;
475 } 478 }
476 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); 479 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
477 } 480 }
478 481
479 } // namespace bin 482 } // namespace bin
480 } // namespace dart 483 } // namespace dart
481 484
482 #endif // defined(TARGET_OS_ANDROID) 485 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/directory_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698