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

Side by Side Diff: runtime/bin/file_macos.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 | « 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } else { 326 } else {
327 errno = ENOENT; 327 errno = ENOENT;
328 } 328 }
329 return false; 329 return false;
330 } 330 }
331 331
332 332
333 int64_t File::LengthFromPath(const char* name) { 333 int64_t File::LengthFromPath(const char* name) {
334 struct stat st; 334 struct stat st;
335 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) { 335 if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
336 // Signal an error if it's a directory.
337 if (S_ISDIR(st.st_mode)) {
338 errno = EISDIR;
339 return -1;
340 }
341 // Otherwise assume the caller knows what it's doing.
336 return st.st_size; 342 return st.st_size;
337 } 343 }
338 return -1; 344 return -1;
339 } 345 }
340 346
341 347
342 static int64_t TimespecToMilliseconds(const struct timespec& t) { 348 static int64_t TimespecToMilliseconds(const struct timespec& t) {
343 return static_cast<int64_t>(t.tv_sec) * 1000L + 349 return static_cast<int64_t>(t.tv_sec) * 1000L +
344 static_cast<int64_t>(t.tv_nsec) / 1000000L; 350 static_cast<int64_t>(t.tv_nsec) / 1000000L;
345 } 351 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return ((file_1_info.st_ino == file_2_info.st_ino) && 505 return ((file_1_info.st_ino == file_2_info.st_ino) &&
500 (file_1_info.st_dev == file_2_info.st_dev)) 506 (file_1_info.st_dev == file_2_info.st_dev))
501 ? File::kIdentical 507 ? File::kIdentical
502 : File::kDifferent; 508 : File::kDifferent;
503 } 509 }
504 510
505 } // namespace bin 511 } // namespace bin
506 } // namespace dart 512 } // namespace dart
507 513
508 #endif // defined(TARGET_OS_MACOS) 514 #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