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

Side by Side Diff: runtime/bin/file_macos.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_linux.cc ('k') | runtime/bin/file_win.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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <copyfile.h> // NOLINT 10 #include <copyfile.h> // NOLINT
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 data[kSize] = st.st_size; 373 data[kSize] = st.st_size;
374 } else { 374 } else {
375 data[kType] = kDoesNotExist; 375 data[kType] = kDoesNotExist;
376 } 376 }
377 } 377 }
378 378
379 379
380 time_t File::LastModified(const char* name) { 380 time_t File::LastModified(const char* name) {
381 struct stat st; 381 struct stat st;
382 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 382 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
383 // Signal an error if it's a directory.
384 if (S_ISDIR(st.st_mode)) {
385 errno = EISDIR;
386 return -1;
387 }
388 // Otherwise assume the caller knows what it's doing.
383 return st.st_mtime; 389 return st.st_mtime;
384 } 390 }
385 return -1; 391 return -1;
386 } 392 }
387 393
388 394
389 const char* File::LinkTarget(const char* pathname) { 395 const char* File::LinkTarget(const char* pathname) {
390 struct stat link_stats; 396 struct stat link_stats;
391 if (lstat(pathname, &link_stats) != 0) { 397 if (lstat(pathname, &link_stats) != 0) {
392 return NULL; 398 return NULL;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return ((file_1_info.st_ino == file_2_info.st_ino) && 511 return ((file_1_info.st_ino == file_2_info.st_ino) &&
506 (file_1_info.st_dev == file_2_info.st_dev)) 512 (file_1_info.st_dev == file_2_info.st_dev))
507 ? File::kIdentical 513 ? File::kIdentical
508 : File::kDifferent; 514 : File::kDifferent;
509 } 515 }
510 516
511 } // namespace bin 517 } // namespace bin
512 } // namespace dart 518 } // namespace dart
513 519
514 #endif // defined(TARGET_OS_MACOS) 520 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698