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/media/device_media_file_util.h" | 5 #include "webkit/fileapi/media/device_media_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 "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "webkit/fileapi/file_system_operation_context.h" | 10 #include "webkit/fileapi/file_system_operation_context.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 last_modified_time); | 109 last_modified_time); |
110 } | 110 } |
111 | 111 |
112 PlatformFileError DeviceMediaFileUtil::Truncate( | 112 PlatformFileError DeviceMediaFileUtil::Truncate( |
113 FileSystemOperationContext* context, | 113 FileSystemOperationContext* context, |
114 const FileSystemURL& url, | 114 const FileSystemURL& url, |
115 int64 length) { | 115 int64 length) { |
116 return base::PLATFORM_FILE_ERROR_SECURITY; | 116 return base::PLATFORM_FILE_ERROR_SECURITY; |
117 } | 117 } |
118 | 118 |
119 bool DeviceMediaFileUtil::PathExists( | |
120 FileSystemOperationContext* context, | |
121 const FileSystemURL& url) { | |
122 if (!context->media_device()) | |
123 return false; | |
124 | |
125 FilePath path; | |
126 PlatformFileInfo file_info; | |
127 PlatformFileError error = GetFileInfo(context, url, &file_info, &path); | |
128 return error == base::PLATFORM_FILE_OK; | |
129 } | |
130 | |
131 bool DeviceMediaFileUtil::DirectoryExists( | |
132 FileSystemOperationContext* context, | |
133 const FileSystemURL& url) { | |
134 if (!context->media_device()) | |
135 return false; | |
136 return context->media_device()->DirectoryExists(url.path()); | |
137 } | |
138 | |
139 bool DeviceMediaFileUtil::IsDirectoryEmpty( | 119 bool DeviceMediaFileUtil::IsDirectoryEmpty( |
140 FileSystemOperationContext* context, | 120 FileSystemOperationContext* context, |
141 const FileSystemURL& url) { | 121 const FileSystemURL& url) { |
142 if (!context->media_device()) | 122 if (!context->media_device()) |
143 return false; | 123 return false; |
144 | 124 |
145 scoped_ptr<AbstractFileEnumerator> enumerator( | 125 scoped_ptr<AbstractFileEnumerator> enumerator( |
146 CreateFileEnumerator(context, url, false)); | 126 CreateFileEnumerator(context, url, false)); |
147 FilePath path; | 127 FilePath path; |
148 while (!(path = enumerator->Next()).empty()) { | 128 while (!(path = enumerator->Next()).empty()) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 LOG(WARNING) << "Could not create a temporary file for media snapshot in " | 194 LOG(WARNING) << "Could not create a temporary file for media snapshot in " |
215 << isolated_media_file_system_dir_path.value(); | 195 << isolated_media_file_system_dir_path.value(); |
216 return base::PLATFORM_FILE_ERROR_FAILED; | 196 return base::PLATFORM_FILE_ERROR_FAILED; |
217 } | 197 } |
218 | 198 |
219 return context->media_device()->CreateSnapshotFile( | 199 return context->media_device()->CreateSnapshotFile( |
220 url.path(), *local_path, file_info); | 200 url.path(), *local_path, file_info); |
221 } | 201 } |
222 | 202 |
223 } // namespace fileapi | 203 } // namespace fileapi |
OLD | NEW |