| 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/browser/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 |
| 11 namespace fileapi { | 11 namespace fileapi { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 // Sets permissions on directory at |dir_path| based on the target platform. | 15 // Sets permissions on directory at |dir_path| based on the target platform. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 PlatformFileError NativeFileUtil::Touch( | 171 PlatformFileError NativeFileUtil::Touch( |
| 172 const base::FilePath& path, | 172 const base::FilePath& path, |
| 173 const base::Time& last_access_time, | 173 const base::Time& last_access_time, |
| 174 const base::Time& last_modified_time) { | 174 const base::Time& last_modified_time) { |
| 175 if (!file_util::TouchFile( | 175 if (!file_util::TouchFile( |
| 176 path, last_access_time, last_modified_time)) | 176 path, last_access_time, last_modified_time)) |
| 177 return base::PLATFORM_FILE_ERROR_FAILED; | 177 return base::PLATFORM_FILE_ERROR_FAILED; |
| 178 return base::PLATFORM_FILE_OK; | 178 return base::PLATFORM_FILE_OK; |
| 179 } | 179 } |
| 180 | 180 |
| 181 PlatformFileError NativeFileUtil::Truncate(const base::FilePath& path, int64 len
gth) { | 181 PlatformFileError NativeFileUtil::Truncate( |
| 182 const base::FilePath& path, int64 length) { |
| 182 PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED); | 183 PlatformFileError error_code(base::PLATFORM_FILE_ERROR_FAILED); |
| 183 PlatformFile file = | 184 PlatformFile file = |
| 184 base::CreatePlatformFile( | 185 base::CreatePlatformFile( |
| 185 path, | 186 path, |
| 186 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE, | 187 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE, |
| 187 NULL, | 188 NULL, |
| 188 &error_code); | 189 &error_code); |
| 189 if (error_code != base::PLATFORM_FILE_OK) { | 190 if (error_code != base::PLATFORM_FILE_OK) { |
| 190 return error_code; | 191 return error_code; |
| 191 } | 192 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 if (!file_util::DirectoryExists(path)) | 256 if (!file_util::DirectoryExists(path)) |
| 256 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; | 257 return base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY; |
| 257 if (!file_util::IsDirectoryEmpty(path)) | 258 if (!file_util::IsDirectoryEmpty(path)) |
| 258 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; | 259 return base::PLATFORM_FILE_ERROR_NOT_EMPTY; |
| 259 if (!file_util::Delete(path, false)) | 260 if (!file_util::Delete(path, false)) |
| 260 return base::PLATFORM_FILE_ERROR_FAILED; | 261 return base::PLATFORM_FILE_ERROR_FAILED; |
| 261 return base::PLATFORM_FILE_OK; | 262 return base::PLATFORM_FILE_OK; |
| 262 } | 263 } |
| 263 | 264 |
| 264 } // namespace fileapi | 265 } // namespace fileapi |
| OLD | NEW |