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/local_file_util.h" | 5 #include "webkit/browser/fileapi/local_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/files/file_util_proxy.h" | 9 #include "base/files/file_util_proxy.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 bool LocalFileEnumerator::IsDirectory() { | 71 bool LocalFileEnumerator::IsDirectory() { |
72 return file_util_info_.IsDirectory(); | 72 return file_util_info_.IsDirectory(); |
73 } | 73 } |
74 | 74 |
75 LocalFileUtil::LocalFileUtil() {} | 75 LocalFileUtil::LocalFileUtil() {} |
76 | 76 |
77 LocalFileUtil::~LocalFileUtil() {} | 77 LocalFileUtil::~LocalFileUtil() {} |
78 | 78 |
79 base::File::Error LocalFileUtil::CreateOrOpen( | 79 base::File LocalFileUtil::CreateOrOpen( |
80 FileSystemOperationContext* context, | 80 FileSystemOperationContext* context, |
81 const FileSystemURL& url, int file_flags, | 81 const FileSystemURL& url, int file_flags) { |
82 base::PlatformFile* file_handle, bool* created) { | |
83 *created = false; | |
84 base::FilePath file_path; | 82 base::FilePath file_path; |
85 base::File::Error error = GetLocalFilePath(context, url, &file_path); | 83 base::File::Error error = GetLocalFilePath(context, url, &file_path); |
86 if (error != base::File::FILE_OK) | 84 if (error != base::File::FILE_OK) |
87 return error; | 85 return base::File(error); |
88 // Disallow opening files in symlinked paths. | 86 // Disallow opening files in symlinked paths. |
89 if (base::IsLink(file_path)) | 87 if (base::IsLink(file_path)) |
90 return base::File::FILE_ERROR_NOT_FOUND; | 88 return base::File(base::File::FILE_ERROR_NOT_FOUND); |
91 | 89 |
92 // TODO(rvargas): make FileSystemFileUtil use base::File. | 90 return NativeFileUtil::CreateOrOpen(file_path, file_flags); |
93 base::File file = NativeFileUtil::CreateOrOpen(file_path, file_flags); | |
94 if (!file.IsValid()) | |
95 return file.error_details(); | |
96 | |
97 *created = file.created(); | |
98 *file_handle = file.TakePlatformFile(); | |
99 return base::File::FILE_OK; | |
100 } | |
101 | |
102 base::File::Error LocalFileUtil::Close(FileSystemOperationContext* context, | |
103 base::PlatformFile file) { | |
104 base::File auto_closed(file); | |
105 return base::File::FILE_OK; | |
106 } | 91 } |
107 | 92 |
108 base::File::Error LocalFileUtil::EnsureFileExists( | 93 base::File::Error LocalFileUtil::EnsureFileExists( |
109 FileSystemOperationContext* context, | 94 FileSystemOperationContext* context, |
110 const FileSystemURL& url, | 95 const FileSystemURL& url, |
111 bool* created) { | 96 bool* created) { |
112 base::FilePath file_path; | 97 base::FilePath file_path; |
113 base::File::Error error = GetLocalFilePath(context, url, &file_path); | 98 base::File::Error error = GetLocalFilePath(context, url, &file_path); |
114 if (error != base::File::FILE_OK) | 99 if (error != base::File::FILE_OK) |
115 return error; | 100 return error; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 base::FilePath* platform_path) { | 252 base::FilePath* platform_path) { |
268 DCHECK(file_info); | 253 DCHECK(file_info); |
269 // We're just returning the local file information. | 254 // We're just returning the local file information. |
270 *error = GetFileInfo(context, url, file_info, platform_path); | 255 *error = GetFileInfo(context, url, file_info, platform_path); |
271 if (*error == base::File::FILE_OK && file_info->is_directory) | 256 if (*error == base::File::FILE_OK && file_info->is_directory) |
272 *error = base::File::FILE_ERROR_NOT_A_FILE; | 257 *error = base::File::FILE_ERROR_NOT_A_FILE; |
273 return webkit_blob::ScopedFile(); | 258 return webkit_blob::ScopedFile(); |
274 } | 259 } |
275 | 260 |
276 } // namespace fileapi | 261 } // namespace fileapi |
OLD | NEW |