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

Unified 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, 12 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_win.cc
diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc
index 79272d3ff73d912544b55c2ec288de92dbae0176..b226e80157f92edb459115fb9acefd38e6b3ef8e 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -444,7 +444,12 @@ int64_t File::LengthFromPath(const char* name) {
Utf8ToWideScope system_name(name);
int stat_status = _wstat64(system_name.wide(), &st);
if (stat_status == 0) {
- return st.st_size;
+ if ((st.st_mode & S_IFMT) == S_IFREG) {
+ return st.st_size;
+ } else {
+ // ERROR_DIRECTORY_NOT_SUPPORTED is not always in the message table.
+ SetLastError(ERROR_NOT_SUPPORTED);
+ }
}
return -1;
}
« 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