| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/fileapi/native_file_util.h" | 5 #include "webkit/fileapi/native_file_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "webkit/fileapi/file_system_operation_context.h" | 9 #include "webkit/fileapi/file_system_operation_context.h" |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return file_util::FileEnumerator::IsDirectory(file_util_info_); | 78 return file_util::FileEnumerator::IsDirectory(file_util_info_); |
| 79 } | 79 } |
| 80 | 80 |
| 81 PlatformFileError NativeFileUtil::CreateOrOpen( | 81 PlatformFileError NativeFileUtil::CreateOrOpen( |
| 82 const base::FilePath& path, int file_flags, | 82 const base::FilePath& path, int file_flags, |
| 83 PlatformFile* file_handle, bool* created) { | 83 PlatformFile* file_handle, bool* created) { |
| 84 if (!file_util::DirectoryExists(path.DirName())) { | 84 if (!file_util::DirectoryExists(path.DirName())) { |
| 85 // If its parent does not exist, should return NOT_FOUND error. | 85 // If its parent does not exist, should return NOT_FOUND error. |
| 86 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 86 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
| 87 } | 87 } |
| 88 if (file_util::DirectoryExists(path)) |
| 89 return base::PLATFORM_FILE_ERROR_NOT_A_FILE; |
| 88 PlatformFileError error_code = base::PLATFORM_FILE_OK; | 90 PlatformFileError error_code = base::PLATFORM_FILE_OK; |
| 89 *file_handle = base::CreatePlatformFile(path, file_flags, | 91 *file_handle = base::CreatePlatformFile(path, file_flags, |
| 90 created, &error_code); | 92 created, &error_code); |
| 91 return error_code; | 93 return error_code; |
| 92 } | 94 } |
| 93 | 95 |
| 94 PlatformFileError NativeFileUtil::Close(PlatformFile file_handle) { | 96 PlatformFileError NativeFileUtil::Close(PlatformFile file_handle) { |
| 95 if (!base::ClosePlatformFile(file_handle)) | 97 if (!base::ClosePlatformFile(file_handle)) |
| 96 return base::PLATFORM_FILE_ERROR_FAILED; | 98 return base::PLATFORM_FILE_ERROR_FAILED; |
| 97 return base::PLATFORM_FILE_OK; | 99 return base::PLATFORM_FILE_OK; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 if (!file_util::DirectoryExists(path)) | 255 if (!file_util::DirectoryExists(path)) |
| 254 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 256 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; |
| 255 if (!file_util::IsDirectoryEmpty(path)) | 257 if (!file_util::IsDirectoryEmpty(path)) |
| 256 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; | 258 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; |
| 257 if (!file_util::Delete(path, false)) | 259 if (!file_util::Delete(path, false)) |
| 258 return base::PLATFORM_FILE_ERROR_FAILED; | 260 return base::PLATFORM_FILE_ERROR_FAILED; |
| 259 return base::PLATFORM_FILE_OK; | 261 return base::PLATFORM_FILE_OK; |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace fileapi | 264 } // namespace fileapi |
| OLD | NEW |