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

Side by Side Diff: runtime/bin/file_linux.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 | « runtime/bin/file_fuchsia.cc ('k') | runtime/bin/file_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/file.h" 8 #include "bin/file.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 data[kSize] = st.st_size; 412 data[kSize] = st.st_size;
413 } else { 413 } else {
414 data[kType] = kDoesNotExist; 414 data[kType] = kDoesNotExist;
415 } 415 }
416 } 416 }
417 417
418 418
419 time_t File::LastModified(const char* name) { 419 time_t File::LastModified(const char* name) {
420 struct stat64 st; 420 struct stat64 st;
421 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { 421 if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) {
422 // Signal an error if it's a directory.
423 if (S_ISDIR(st.st_mode)) {
424 errno = EISDIR;
425 return -1;
426 }
427 // Otherwise assume the caller knows what it's doing.
422 return st.st_mtime; 428 return st.st_mtime;
423 } 429 }
424 return -1; 430 return -1;
425 } 431 }
426 432
427 433
428 const char* File::LinkTarget(const char* pathname) { 434 const char* File::LinkTarget(const char* pathname) {
429 struct stat64 link_stats; 435 struct stat64 link_stats;
430 if (TEMP_FAILURE_RETRY(lstat64(pathname, &link_stats)) != 0) { 436 if (TEMP_FAILURE_RETRY(lstat64(pathname, &link_stats)) != 0) {
431 return NULL; 437 return NULL;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return ((file_1_info.st_ino == file_2_info.st_ino) && 548 return ((file_1_info.st_ino == file_2_info.st_ino) &&
543 (file_1_info.st_dev == file_2_info.st_dev)) 549 (file_1_info.st_dev == file_2_info.st_dev))
544 ? File::kIdentical 550 ? File::kIdentical
545 : File::kDifferent; 551 : File::kDifferent;
546 } 552 }
547 553
548 } // namespace bin 554 } // namespace bin
549 } // namespace dart 555 } // namespace dart
550 556
551 #endif // defined(TARGET_OS_LINUX) 557 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/file_fuchsia.cc ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698