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

Side by Side Diff: runtime/bin/directory_fuchsia.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 | « runtime/bin/directory_android.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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_FUCHSIA) 6 #if defined(TARGET_OS_FUCHSIA)
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 } 242 }
243 243
244 244
245 Directory::ExistsResult Directory::Exists(const char* dir_name) { 245 Directory::ExistsResult Directory::Exists(const char* dir_name) {
246 struct stat entry_info; 246 struct stat entry_info;
247 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info)); 247 int success = NO_RETRY_EXPECTED(stat(dir_name, &entry_info));
248 if (success == 0) { 248 if (success == 0) {
249 if (S_ISDIR(entry_info.st_mode)) { 249 if (S_ISDIR(entry_info.st_mode)) {
250 return EXISTS; 250 return EXISTS;
251 } else { 251 } else {
252 // An OSError may be constructed based on the return value of this
253 // function, so set errno to something that makes sense.
254 errno = ENOTDIR;
252 return DOES_NOT_EXIST; 255 return DOES_NOT_EXIST;
253 } 256 }
254 } else { 257 } else {
255 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) || 258 if ((errno == EACCES) || (errno == EBADF) || (errno == EFAULT) ||
256 (errno == ENOMEM) || (errno == EOVERFLOW)) { 259 (errno == ENOMEM) || (errno == EOVERFLOW)) {
257 // Search permissions denied for one of the directories in the 260 // Search permissions denied for one of the directories in the
258 // path or a low level error occured. We do not know if the 261 // path or a low level error occured. We do not know if the
259 // directory exists. 262 // directory exists.
260 return UNKNOWN; 263 return UNKNOWN;
261 } 264 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 if (exists != EXISTS) { 366 if (exists != EXISTS) {
364 return false; 367 return false;
365 } 368 }
366 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0); 369 return (NO_RETRY_EXPECTED(rename(path, new_path)) == 0);
367 } 370 }
368 371
369 } // namespace bin 372 } // namespace bin
370 } // namespace dart 373 } // namespace dart
371 374
372 #endif // defined(TARGET_OS_FUCHSIA) 375 #endif // defined(TARGET_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/bin/directory_android.cc ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698