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

Side by Side Diff: runtime/bin/file_win.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_macos.cc ('k') | tests/standalone/io/file_test.dart » ('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_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <fcntl.h> // NOLINT 10 #include <fcntl.h> // NOLINT
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 437 }
438 return false; 438 return false;
439 } 439 }
440 440
441 441
442 int64_t File::LengthFromPath(const char* name) { 442 int64_t File::LengthFromPath(const char* name) {
443 struct __stat64 st; 443 struct __stat64 st;
444 Utf8ToWideScope system_name(name); 444 Utf8ToWideScope system_name(name);
445 int stat_status = _wstat64(system_name.wide(), &st); 445 int stat_status = _wstat64(system_name.wide(), &st);
446 if (stat_status == 0) { 446 if (stat_status == 0) {
447 return st.st_size; 447 if ((st.st_mode & S_IFMT) == S_IFREG) {
448 return st.st_size;
449 } else {
450 // ERROR_DIRECTORY_NOT_SUPPORTED is not always in the message table.
451 SetLastError(ERROR_NOT_SUPPORTED);
452 }
448 } 453 }
449 return -1; 454 return -1;
450 } 455 }
451 456
452 457
453 const char* File::LinkTarget(const char* pathname) { 458 const char* File::LinkTarget(const char* pathname) {
454 const wchar_t* name = StringUtilsWin::Utf8ToWide(pathname); 459 const wchar_t* name = StringUtilsWin::Utf8ToWide(pathname);
455 HANDLE dir_handle = CreateFileW( 460 HANDLE dir_handle = CreateFileW(
456 name, GENERIC_READ, 461 name, GENERIC_READ,
457 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, 462 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 return kIdentical; 676 return kIdentical;
672 } else { 677 } else {
673 return kDifferent; 678 return kDifferent;
674 } 679 }
675 } 680 }
676 681
677 } // namespace bin 682 } // namespace bin
678 } // namespace dart 683 } // namespace dart
679 684
680 #endif // defined(TARGET_OS_WINDOWS) 685 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698