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/browser/fileapi/native_file_util.h" | 5 #include "webkit/browser/fileapi/native_file_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "webkit/browser/fileapi/file_system_operation_context.h" | 10 #include "webkit/browser/fileapi/file_system_operation_context.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 130 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
131 | 131 |
132 bool path_exists = base::PathExists(path); | 132 bool path_exists = base::PathExists(path); |
133 if (exclusive && path_exists) | 133 if (exclusive && path_exists) |
134 return base::PLATFORM_FILE_ERROR_EXISTS; | 134 return base::PLATFORM_FILE_ERROR_EXISTS; |
135 | 135 |
136 // If file exists at the path. | 136 // If file exists at the path. |
137 if (path_exists && !base::DirectoryExists(path)) | 137 if (path_exists && !base::DirectoryExists(path)) |
138 return base::PLATFORM_FILE_ERROR_EXISTS; | 138 return base::PLATFORM_FILE_ERROR_EXISTS; |
139 | 139 |
140 if (!file_util::CreateDirectory(path)) | 140 if (!base::CreateDirectory(path)) |
141 return base::PLATFORM_FILE_ERROR_FAILED; | 141 return base::PLATFORM_FILE_ERROR_FAILED; |
142 | 142 |
143 if (!SetPlatformSpecificDirectoryPermissions(path)) { | 143 if (!SetPlatformSpecificDirectoryPermissions(path)) { |
144 // Since some file systems don't support permission setting, we do not treat | 144 // Since some file systems don't support permission setting, we do not treat |
145 // an error from the function as the failure of copying. Just log it. | 145 // an error from the function as the failure of copying. Just log it. |
146 LOG(WARNING) << "Setting directory permission failed: " | 146 LOG(WARNING) << "Setting directory permission failed: " |
147 << path.AsUTF8Unsafe(); | 147 << path.AsUTF8Unsafe(); |
148 } | 148 } |
149 | 149 |
150 return base::PLATFORM_FILE_OK; | 150 return base::PLATFORM_FILE_OK; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 if (!base::DirectoryExists(path)) | 265 if (!base::DirectoryExists(path)) |
266 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 266 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; |
267 if (!base::IsDirectoryEmpty(path)) | 267 if (!base::IsDirectoryEmpty(path)) |
268 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; | 268 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; |
269 if (!base::DeleteFile(path, false)) | 269 if (!base::DeleteFile(path, false)) |
270 return base::PLATFORM_FILE_ERROR_FAILED; | 270 return base::PLATFORM_FILE_ERROR_FAILED; |
271 return base::PLATFORM_FILE_OK; | 271 return base::PLATFORM_FILE_OK; |
272 } | 272 } |
273 | 273 |
274 } // namespace fileapi | 274 } // namespace fileapi |
OLD | NEW |