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

Unified Diff: base/file_util_proxy.cc

Issue 3729001: Return NOT_FOUND error for an attempt to create a file under nonexistent directory. (Closed)
Patch Set: rebased Created 10 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_proxy.cc
diff --git a/base/file_util_proxy.cc b/base/file_util_proxy.cc
index b3b18f838c4baa6f01562890bde0e4b44ebc14d1..3175fb2520e7e305b5252e8eebfdc2d6221e41e9 100644
--- a/base/file_util_proxy.cc
+++ b/base/file_util_proxy.cc
@@ -136,6 +136,11 @@ class RelayCreateOrOpen : public MessageLoopRelay {
}
virtual void RunWork() {
+ if (!file_util::DirectoryExists(file_path_.DirName())) {
+ // If its parent does not exist, should return NOT_FOUND error.
+ set_error_code(base::PLATFORM_FILE_ERROR_NOT_FOUND);
+ return;
+ }
base::PlatformFileError error_code = base::PLATFORM_FILE_OK;
file_handle_ = base::CreatePlatformFile(file_path_, file_flags_,
&created_, &error_code);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698