| 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/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "webkit/fileapi/file_system_operation_context.h" | 9 #include "webkit/fileapi/file_system_operation_context.h" |
| 10 #include "webkit/fileapi/file_system_url.h" | 10 #include "webkit/fileapi/file_system_url.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return base::PLATFORM_FILE_ERROR_FAILED; | 115 return base::PLATFORM_FILE_ERROR_FAILED; |
| 116 } | 116 } |
| 117 | 117 |
| 118 PlatformFileError DeviceMediaFileUtil::Truncate( | 118 PlatformFileError DeviceMediaFileUtil::Truncate( |
| 119 FileSystemOperationContext* context, | 119 FileSystemOperationContext* context, |
| 120 const FileSystemURL& url, | 120 const FileSystemURL& url, |
| 121 int64 length) { | 121 int64 length) { |
| 122 return base::PLATFORM_FILE_ERROR_FAILED; | 122 return base::PLATFORM_FILE_ERROR_FAILED; |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool DeviceMediaFileUtil::IsDirectoryEmpty( | |
| 126 FileSystemOperationContext* context, | |
| 127 const FileSystemURL& url) { | |
| 128 MTPDeviceDelegate* delegate = GetMTPDeviceDelegate(context); | |
| 129 if (!delegate) | |
| 130 return false; | |
| 131 | |
| 132 scoped_ptr<AbstractFileEnumerator> enumerator( | |
| 133 CreateFileEnumerator(context, url, false)); | |
| 134 FilePath path; | |
| 135 while (!(path = enumerator->Next()).empty()) { | |
| 136 if (enumerator->IsDirectory() || | |
| 137 context->media_path_filter()->Match(path)) | |
| 138 return false; | |
| 139 } | |
| 140 return true; | |
| 141 } | |
| 142 | |
| 143 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile( | 125 PlatformFileError DeviceMediaFileUtil::CopyOrMoveFile( |
| 144 FileSystemOperationContext* context, | 126 FileSystemOperationContext* context, |
| 145 const FileSystemURL& src_url, | 127 const FileSystemURL& src_url, |
| 146 const FileSystemURL& dest_url, | 128 const FileSystemURL& dest_url, |
| 147 bool copy) { | 129 bool copy) { |
| 148 return base::PLATFORM_FILE_ERROR_SECURITY; | 130 return base::PLATFORM_FILE_ERROR_SECURITY; |
| 149 } | 131 } |
| 150 | 132 |
| 151 PlatformFileError DeviceMediaFileUtil::CopyInForeignFile( | 133 PlatformFileError DeviceMediaFileUtil::CopyInForeignFile( |
| 152 FileSystemOperationContext* context, | 134 FileSystemOperationContext* context, |
| 153 const FilePath& src_file_path, | 135 const FilePath& src_file_path, |
| 154 const FileSystemURL& dest_url) { | 136 const FileSystemURL& dest_url) { |
| 155 return base::PLATFORM_FILE_ERROR_SECURITY; | 137 return base::PLATFORM_FILE_ERROR_SECURITY; |
| 156 } | 138 } |
| 157 | 139 |
| 158 PlatformFileError DeviceMediaFileUtil::DeleteFile( | 140 PlatformFileError DeviceMediaFileUtil::DeleteFile( |
| 159 FileSystemOperationContext* context, | 141 FileSystemOperationContext* context, |
| 160 const FileSystemURL& url) { | 142 const FileSystemURL& url) { |
| 161 return base::PLATFORM_FILE_ERROR_SECURITY; | 143 return base::PLATFORM_FILE_ERROR_SECURITY; |
| 162 } | 144 } |
| 163 | 145 |
| 164 PlatformFileError DeviceMediaFileUtil::DeleteSingleDirectory( | 146 PlatformFileError DeviceMediaFileUtil::DeleteDirectory( |
| 165 FileSystemOperationContext* context, | 147 FileSystemOperationContext* context, |
| 166 const FileSystemURL& url) { | 148 const FileSystemURL& url) { |
| 167 return base::PLATFORM_FILE_ERROR_SECURITY; | 149 return base::PLATFORM_FILE_ERROR_SECURITY; |
| 168 } | 150 } |
| 169 | 151 |
| 170 base::PlatformFileError DeviceMediaFileUtil::CreateSnapshotFile( | 152 base::PlatformFileError DeviceMediaFileUtil::CreateSnapshotFile( |
| 171 FileSystemOperationContext* context, | 153 FileSystemOperationContext* context, |
| 172 const FileSystemURL& url, | 154 const FileSystemURL& url, |
| 173 base::PlatformFileInfo* file_info, | 155 base::PlatformFileInfo* file_info, |
| 174 FilePath* local_path, | 156 FilePath* local_path, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 199 isolated_media_file_system_dir_path, local_path); | 181 isolated_media_file_system_dir_path, local_path); |
| 200 if (!file_created) { | 182 if (!file_created) { |
| 201 LOG(WARNING) << "Could not create a temporary file for media snapshot in " | 183 LOG(WARNING) << "Could not create a temporary file for media snapshot in " |
| 202 << isolated_media_file_system_dir_path.value(); | 184 << isolated_media_file_system_dir_path.value(); |
| 203 return base::PLATFORM_FILE_ERROR_FAILED; | 185 return base::PLATFORM_FILE_ERROR_FAILED; |
| 204 } | 186 } |
| 205 return delegate->CreateSnapshotFile(url.path(), *local_path, file_info); | 187 return delegate->CreateSnapshotFile(url.path(), *local_path, file_info); |
| 206 } | 188 } |
| 207 | 189 |
| 208 } // namespace fileapi | 190 } // namespace fileapi |
| OLD | NEW |