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

Unified Diff: runtime/bin/file_win.cc

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Style issues Created 8 years, 9 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') | runtime/bin/io_sources.gypi » ('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 98e73f4ace400e109ae877a5885bcf99b39e72ae..c598380db140b948651da597483807531632a853 100644
--- a/runtime/bin/file_win.cc
+++ b/runtime/bin/file_win.cc
@@ -167,6 +167,11 @@ bool File::IsAbsolutePath(const char* pathname) {
char* File::GetCanonicalPath(const char* pathname) {
+ struct stat st;
+ if (stat(pathname, &st) != 0) {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ return NULL;
+ }
int required_size = GetFullPathName(pathname, 0, NULL, NULL);
char* path = static_cast<char*>(malloc(required_size));
int written = GetFullPathName(pathname, required_size, path, NULL);
@@ -176,6 +181,16 @@ char* File::GetCanonicalPath(const char* pathname) {
char* File::GetContainingDirectory(char* pathname) {
+ struct stat st;
+ if (stat(pathname, &st) == 0) {
+ if ((st.st_mode & S_IFMT) != S_IFREG) {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ return NULL;
+ }
+ } else {
+ SetLastError(ERROR_FILE_NOT_FOUND);
+ return NULL;
+ }
int required_size = GetFullPathName(pathname, 0, NULL, NULL);
char* path = static_cast<char*>(malloc(required_size));
char* file_part = NULL;
« no previous file with comments | « runtime/bin/file_macos.cc ('k') | runtime/bin/io_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698