| 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 "base/files/file_util_proxy.h" | 5 #include "base/files/file_util_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 return PLATFORM_FILE_ERROR_FAILED; | 212 return PLATFORM_FILE_ERROR_FAILED; |
| 213 } | 213 } |
| 214 return PLATFORM_FILE_OK; | 214 return PLATFORM_FILE_OK; |
| 215 } | 215 } |
| 216 | 216 |
| 217 #if !defined(OS_NACL) | 217 #if !defined(OS_NACL) |
| 218 PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { | 218 PlatformFileError DeleteAdapter(const FilePath& file_path, bool recursive) { |
| 219 if (!PathExists(file_path)) { | 219 if (!PathExists(file_path)) { |
| 220 return PLATFORM_FILE_ERROR_NOT_FOUND; | 220 return PLATFORM_FILE_ERROR_NOT_FOUND; |
| 221 } | 221 } |
| 222 if (!base::Delete(file_path, recursive)) { | 222 if (!base::DeleteFile(file_path, recursive)) { |
| 223 if (!recursive && !file_util::IsDirectoryEmpty(file_path)) { | 223 if (!recursive && !file_util::IsDirectoryEmpty(file_path)) { |
| 224 return PLATFORM_FILE_ERROR_NOT_EMPTY; | 224 return PLATFORM_FILE_ERROR_NOT_EMPTY; |
| 225 } | 225 } |
| 226 return PLATFORM_FILE_ERROR_FAILED; | 226 return PLATFORM_FILE_ERROR_FAILED; |
| 227 } | 227 } |
| 228 return PLATFORM_FILE_OK; | 228 return PLATFORM_FILE_OK; |
| 229 } | 229 } |
| 230 #endif // !defined(OS_NACL) | 230 #endif // !defined(OS_NACL) |
| 231 | 231 |
| 232 } // namespace | 232 } // namespace |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 GetFileInfoHelper* helper = new GetFileInfoHelper; | 293 GetFileInfoHelper* helper = new GetFileInfoHelper; |
| 294 return task_runner->PostTaskAndReply( | 294 return task_runner->PostTaskAndReply( |
| 295 FROM_HERE, | 295 FROM_HERE, |
| 296 Bind(&GetFileInfoHelper::RunWorkForPlatformFile, | 296 Bind(&GetFileInfoHelper::RunWorkForPlatformFile, |
| 297 Unretained(helper), file), | 297 Unretained(helper), file), |
| 298 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); | 298 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 #if !defined(OS_NACL) | 301 #if !defined(OS_NACL) |
| 302 // static | 302 // static |
| 303 bool FileUtilProxy::Delete(TaskRunner* task_runner, | 303 bool FileUtilProxy::DeleteFile(TaskRunner* task_runner, |
| 304 const FilePath& file_path, | 304 const FilePath& file_path, |
| 305 bool recursive, | 305 bool recursive, |
| 306 const StatusCallback& callback) { | 306 const StatusCallback& callback) { |
| 307 return base::PostTaskAndReplyWithResult( | 307 return base::PostTaskAndReplyWithResult( |
| 308 task_runner, FROM_HERE, | 308 task_runner, FROM_HERE, |
| 309 Bind(&DeleteAdapter, file_path, recursive), | 309 Bind(&DeleteAdapter, file_path, recursive), |
| 310 callback); | 310 callback); |
| 311 } | 311 } |
| 312 | |
| 313 // static | |
| 314 bool FileUtilProxy::RecursiveDelete( | |
| 315 TaskRunner* task_runner, | |
| 316 const FilePath& file_path, | |
| 317 const StatusCallback& callback) { | |
| 318 return base::PostTaskAndReplyWithResult( | |
| 319 task_runner, FROM_HERE, | |
| 320 Bind(&DeleteAdapter, file_path, true /* recursive */), | |
| 321 callback); | |
| 322 } | |
| 323 #endif // !defined(OS_NACL) | 312 #endif // !defined(OS_NACL) |
| 324 | 313 |
| 325 // static | 314 // static |
| 326 bool FileUtilProxy::Read( | 315 bool FileUtilProxy::Read( |
| 327 TaskRunner* task_runner, | 316 TaskRunner* task_runner, |
| 328 PlatformFile file, | 317 PlatformFile file, |
| 329 int64 offset, | 318 int64 offset, |
| 330 int bytes_to_read, | 319 int bytes_to_read, |
| 331 const ReadCallback& callback) { | 320 const ReadCallback& callback) { |
| 332 if (bytes_to_read < 0) { | 321 if (bytes_to_read < 0) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 bool FileUtilProxy::RelayClose( | 421 bool FileUtilProxy::RelayClose( |
| 433 TaskRunner* task_runner, | 422 TaskRunner* task_runner, |
| 434 const CloseTask& close_task, | 423 const CloseTask& close_task, |
| 435 PlatformFile file_handle, | 424 PlatformFile file_handle, |
| 436 const StatusCallback& callback) { | 425 const StatusCallback& callback) { |
| 437 return base::PostTaskAndReplyWithResult( | 426 return base::PostTaskAndReplyWithResult( |
| 438 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); | 427 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); |
| 439 } | 428 } |
| 440 | 429 |
| 441 } // namespace base | 430 } // namespace base |
| OLD | NEW |