OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_system_file_util.h" | 5 #include "webkit/fileapi/file_system_file_util.h" |
6 | 6 |
7 #include "base/file_util_proxy.h" | 7 #include "base/file_util_proxy.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 | 10 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 227 |
228 // Now it is ok to return if the |dest_file_path| does not exist. | 228 // Now it is ok to return if the |dest_file_path| does not exist. |
229 if (!PathExists(context, dest_file_path)) | 229 if (!PathExists(context, dest_file_path)) |
230 return base::PLATFORM_FILE_OK; | 230 return base::PLATFORM_FILE_OK; |
231 | 231 |
232 // |src_file_path| exists and is a directory. | 232 // |src_file_path| exists and is a directory. |
233 // |dest_file_path| exists and is a file. | 233 // |dest_file_path| exists and is a file. |
234 bool src_is_directory = DirectoryExists(context, src_file_path); | 234 bool src_is_directory = DirectoryExists(context, src_file_path); |
235 bool dest_is_directory = DirectoryExists(context, dest_file_path); | 235 bool dest_is_directory = DirectoryExists(context, dest_file_path); |
236 if (src_is_directory && !dest_is_directory) | 236 if (src_is_directory && !dest_is_directory) |
237 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 237 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
238 | 238 |
239 // |src_file_path| exists and is a file. | 239 // |src_file_path| exists and is a file. |
240 // |dest_file_path| exists and is a directory. | 240 // |dest_file_path| exists and is a directory. |
241 if (!src_is_directory && dest_is_directory) | 241 if (!src_is_directory && dest_is_directory) |
242 return base::PLATFORM_FILE_ERROR_NOT_A_FILE; | 242 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; |
243 | 243 |
244 // It is an error to copy/move an entry into the same path. | 244 // It is an error to copy/move an entry into the same path. |
245 if (src_file_path.value() == dest_file_path.value()) | 245 if (src_file_path.value() == dest_file_path.value()) |
246 return base::PLATFORM_FILE_ERROR_EXISTS; | 246 return base::PLATFORM_FILE_ERROR_EXISTS; |
247 | 247 |
248 if (dest_is_directory) { | 248 if (dest_is_directory) { |
249 // It is an error to copy/move an entry to a non-empty directory. | 249 // It is an error to copy/move an entry to a non-empty directory. |
250 // Otherwise the copy/move attempt must overwrite the destination, but | 250 // Otherwise the copy/move attempt must overwrite the destination, but |
251 // the file_util's Copy or Move method doesn't perform overwrite | 251 // the file_util's Copy or Move method doesn't perform overwrite |
252 // on all platforms, so we delete the destination directory here. | 252 // on all platforms, so we delete the destination directory here. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 365 |
366 FileSystemFileUtil::AbstractFileEnumerator* | 366 FileSystemFileUtil::AbstractFileEnumerator* |
367 FileSystemFileUtil::CreateFileEnumerator(const FilePath& root_path) { | 367 FileSystemFileUtil::CreateFileEnumerator(const FilePath& root_path) { |
368 return new FileSystemFileEnumerator( | 368 return new FileSystemFileEnumerator( |
369 root_path, true, static_cast<file_util::FileEnumerator::FILE_TYPE>( | 369 root_path, true, static_cast<file_util::FileEnumerator::FILE_TYPE>( |
370 file_util::FileEnumerator::FILES | | 370 file_util::FileEnumerator::FILES | |
371 file_util::FileEnumerator::DIRECTORIES)); | 371 file_util::FileEnumerator::DIRECTORIES)); |
372 } | 372 } |
373 | 373 |
374 } // namespace fileapi | 374 } // namespace fileapi |
OLD | NEW |