Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: webkit/fileapi/local_file_util.cc

Issue 11960003: Cleanup: Move more recursive operation logic from FileUtilHelper to FileUtil (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/local_file_util.h ('k') | webkit/fileapi/media/device_media_file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/local_file_util.h" 5 #include "webkit/fileapi/local_file_util.h"
6 6
7 #include "base/file_util_proxy.h" 7 #include "base/file_util_proxy.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "webkit/fileapi/file_system_context.h" 9 #include "webkit/fileapi/file_system_context.h"
10 #include "webkit/fileapi/file_system_mount_point_provider.h" 10 #include "webkit/fileapi/file_system_mount_point_provider.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 FileSystemOperationContext* context, 184 FileSystemOperationContext* context,
185 const FileSystemURL& url, 185 const FileSystemURL& url,
186 int64 length) { 186 int64 length) {
187 FilePath file_path; 187 FilePath file_path;
188 PlatformFileError error = GetLocalFilePath(context, url, &file_path); 188 PlatformFileError error = GetLocalFilePath(context, url, &file_path);
189 if (error != base::PLATFORM_FILE_OK) 189 if (error != base::PLATFORM_FILE_OK)
190 return error; 190 return error;
191 return NativeFileUtil::Truncate(file_path, length); 191 return NativeFileUtil::Truncate(file_path, length);
192 } 192 }
193 193
194 bool LocalFileUtil::IsDirectoryEmpty(
195 FileSystemOperationContext* context,
196 const FileSystemURL& url) {
197 FilePath file_path;
198 if (GetLocalFilePath(context, url, &file_path) != base::PLATFORM_FILE_OK)
199 return true;
200 return NativeFileUtil::IsDirectoryEmpty(file_path);
201 }
202
203 PlatformFileError LocalFileUtil::CopyOrMoveFile( 194 PlatformFileError LocalFileUtil::CopyOrMoveFile(
204 FileSystemOperationContext* context, 195 FileSystemOperationContext* context,
205 const FileSystemURL& src_url, 196 const FileSystemURL& src_url,
206 const FileSystemURL& dest_url, 197 const FileSystemURL& dest_url,
207 bool copy) { 198 bool copy) {
208 FilePath src_file_path; 199 FilePath src_file_path;
209 PlatformFileError error = GetLocalFilePath(context, src_url, &src_file_path); 200 PlatformFileError error = GetLocalFilePath(context, src_url, &src_file_path);
210 if (error != base::PLATFORM_FILE_OK) 201 if (error != base::PLATFORM_FILE_OK)
211 return error; 202 return error;
212 203
213 FilePath dest_file_path; 204 FilePath dest_file_path;
214 error = GetLocalFilePath(context, dest_url, &dest_file_path); 205 error = GetLocalFilePath(context, dest_url, &dest_file_path);
215 if (error != base::PLATFORM_FILE_OK) 206 if (error != base::PLATFORM_FILE_OK)
216 return error; 207 return error;
217 208
218 return NativeFileUtil::CopyOrMoveFile(src_file_path, dest_file_path, copy); 209 return NativeFileUtil::CopyOrMoveFile(src_file_path, dest_file_path, copy);
219 } 210 }
220 211
221 // TODO(dmikurube): Make it independent from CopyOrMoveFile.
222 PlatformFileError LocalFileUtil::CopyInForeignFile( 212 PlatformFileError LocalFileUtil::CopyInForeignFile(
223 FileSystemOperationContext* context, 213 FileSystemOperationContext* context,
224 const FilePath& src_file_path, 214 const FilePath& src_file_path,
225 const FileSystemURL& dest_url) { 215 const FileSystemURL& dest_url) {
226 if (src_file_path.empty()) 216 if (src_file_path.empty())
227 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION; 217 return base::PLATFORM_FILE_ERROR_INVALID_OPERATION;
228 218
229 FilePath dest_file_path; 219 FilePath dest_file_path;
230 PlatformFileError error = 220 PlatformFileError error =
231 GetLocalFilePath(context, dest_url, &dest_file_path); 221 GetLocalFilePath(context, dest_url, &dest_file_path);
232 if (error != base::PLATFORM_FILE_OK) 222 if (error != base::PLATFORM_FILE_OK)
233 return error; 223 return error;
234 return NativeFileUtil::CopyOrMoveFile(src_file_path, dest_file_path, true); 224 return NativeFileUtil::CopyOrMoveFile(src_file_path, dest_file_path, true);
235 } 225 }
236 226
237 PlatformFileError LocalFileUtil::DeleteFile( 227 PlatformFileError LocalFileUtil::DeleteFile(
238 FileSystemOperationContext* context, 228 FileSystemOperationContext* context,
239 const FileSystemURL& url) { 229 const FileSystemURL& url) {
240 FilePath file_path; 230 FilePath file_path;
241 PlatformFileError error = GetLocalFilePath(context, url, &file_path); 231 PlatformFileError error = GetLocalFilePath(context, url, &file_path);
242 if (error != base::PLATFORM_FILE_OK) 232 if (error != base::PLATFORM_FILE_OK)
243 return error; 233 return error;
244 return NativeFileUtil::DeleteFile(file_path); 234 return NativeFileUtil::DeleteFile(file_path);
245 } 235 }
246 236
247 PlatformFileError LocalFileUtil::DeleteSingleDirectory( 237 PlatformFileError LocalFileUtil::DeleteDirectory(
248 FileSystemOperationContext* context, 238 FileSystemOperationContext* context,
249 const FileSystemURL& url) { 239 const FileSystemURL& url) {
250 FilePath file_path; 240 FilePath file_path;
251 PlatformFileError error = GetLocalFilePath(context, url, &file_path); 241 PlatformFileError error = GetLocalFilePath(context, url, &file_path);
252 if (error != base::PLATFORM_FILE_OK) 242 if (error != base::PLATFORM_FILE_OK)
253 return error; 243 return error;
254 return NativeFileUtil::DeleteSingleDirectory(file_path); 244 return NativeFileUtil::DeleteDirectory(file_path);
255 } 245 }
256 246
257 base::PlatformFileError LocalFileUtil::CreateSnapshotFile( 247 base::PlatformFileError LocalFileUtil::CreateSnapshotFile(
258 FileSystemOperationContext* context, 248 FileSystemOperationContext* context,
259 const FileSystemURL& url, 249 const FileSystemURL& url,
260 base::PlatformFileInfo* file_info, 250 base::PlatformFileInfo* file_info,
261 FilePath* platform_path, 251 FilePath* platform_path,
262 SnapshotFilePolicy* policy) { 252 SnapshotFilePolicy* policy) {
263 DCHECK(policy); 253 DCHECK(policy);
254 DCHECK(file_info);
264 // We're just returning the local file information. 255 // We're just returning the local file information.
265 *policy = kSnapshotFileLocal; 256 *policy = kSnapshotFileLocal;
266 return GetFileInfo(context, url, file_info, platform_path); 257 base::PlatformFileError error =
258 GetFileInfo(context, url, file_info, platform_path);
259 if (error == base::PLATFORM_FILE_OK && file_info->is_directory)
260 return base::PLATFORM_FILE_ERROR_NOT_A_FILE;
261 return error;
267 } 262 }
268 263
269 } // namespace fileapi 264 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_util.h ('k') | webkit/fileapi/media/device_media_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698