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

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

Issue 2616463004: Signal an error for File.lastModified on a directory (Closed)
Patch Set: 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 data[kSize] = st.st_size; 404 data[kSize] = st.st_size;
405 } else { 405 } else {
406 data[kType] = kDoesNotExist; 406 data[kType] = kDoesNotExist;
407 } 407 }
408 } 408 }
409 409
410 410
411 time_t File::LastModified(const char* name) { 411 time_t File::LastModified(const char* name) {
412 struct stat st; 412 struct stat st;
413 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 413 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
414 // Signal an error if it's a directory.
415 if (S_ISDIR(st.st_mode)) {
416 errno = EISDIR;
417 return -1;
418 }
419 // Otherwise assume the caller knows what it's doing.
414 return st.st_mtime; 420 return st.st_mtime;
415 } 421 }
416 return -1; 422 return -1;
417 } 423 }
418 424
419 425
420 const char* File::LinkTarget(const char* pathname) { 426 const char* File::LinkTarget(const char* pathname) {
421 struct stat link_stats; 427 struct stat link_stats;
422 if (lstat(pathname, &link_stats) != 0) { 428 if (lstat(pathname, &link_stats) != 0) {
423 return NULL; 429 return NULL;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 return ((file_1_info.st_ino == file_2_info.st_ino) && 534 return ((file_1_info.st_ino == file_2_info.st_ino) &&
529 (file_1_info.st_dev == file_2_info.st_dev)) 535 (file_1_info.st_dev == file_2_info.st_dev))
530 ? File::kIdentical 536 ? File::kIdentical
531 : File::kDifferent; 537 : File::kDifferent;
532 } 538 }
533 539
534 } // namespace bin 540 } // namespace bin
535 } // namespace dart 541 } // namespace dart
536 542
537 #endif // defined(TARGET_OS_ANDROID) 543 #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