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

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

Issue 2615473002: Signal an error for File.length on a directory (Closed)
Patch Set: Fix windows error code Created 3 years, 11 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 | « no previous file | runtime/bin/file_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/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } else { 366 } else {
367 errno = ENOENT; 367 errno = ENOENT;
368 } 368 }
369 return false; 369 return false;
370 } 370 }
371 371
372 372
373 int64_t File::LengthFromPath(const char* name) { 373 int64_t File::LengthFromPath(const char* name) {
374 struct stat st; 374 struct stat st;
375 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 375 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
376 // Signal an error if it's a directory.
377 if (S_ISDIR(st.st_mode)) {
378 errno = EISDIR;
379 return -1;
380 }
381 // Otherwise assume the caller knows what it's doing.
376 return st.st_size; 382 return st.st_size;
377 } 383 }
378 return -1; 384 return -1;
379 } 385 }
380 386
381 387
382 void File::Stat(const char* name, int64_t* data) { 388 void File::Stat(const char* name, int64_t* data) {
383 struct stat st; 389 struct stat st;
384 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 390 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
385 if (S_ISREG(st.st_mode)) { 391 if (S_ISREG(st.st_mode)) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 return ((file_1_info.st_ino == file_2_info.st_ino) && 528 return ((file_1_info.st_ino == file_2_info.st_ino) &&
523 (file_1_info.st_dev == file_2_info.st_dev)) 529 (file_1_info.st_dev == file_2_info.st_dev))
524 ? File::kIdentical 530 ? File::kIdentical
525 : File::kDifferent; 531 : File::kDifferent;
526 } 532 }
527 533
528 } // namespace bin 534 } // namespace bin
529 } // namespace dart 535 } // namespace dart
530 536
531 #endif // defined(TARGET_OS_ANDROID) 537 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/file_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698