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/native_media_file_util.h" | 5 #include "webkit/fileapi/media/native_media_file_util.h" |
6 | 6 |
7 #include "net/base/mime_util.h" | 7 #include "net/base/mime_util.h" |
8 #include "webkit/fileapi/file_system_operation_context.h" | 8 #include "webkit/fileapi/file_system_operation_context.h" |
9 #include "webkit/fileapi/media/media_path_filter.h" | 9 #include "webkit/fileapi/media/media_path_filter.h" |
10 #include "webkit/fileapi/media/filtering_file_enumerator.h" | 10 #include "webkit/fileapi/media/filtering_file_enumerator.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 PlatformFileError NativeMediaFileUtil::Truncate( | 65 PlatformFileError NativeMediaFileUtil::Truncate( |
66 FileSystemOperationContext* context, | 66 FileSystemOperationContext* context, |
67 const FileSystemURL& url, | 67 const FileSystemURL& url, |
68 int64 length) { | 68 int64 length) { |
69 // TODO(tzik): Apply context()->media_path_filter() here when we support write | 69 // TODO(tzik): Apply context()->media_path_filter() here when we support write |
70 // access. | 70 // access. |
71 return base::PLATFORM_FILE_ERROR_SECURITY; | 71 return base::PLATFORM_FILE_ERROR_SECURITY; |
72 } | 72 } |
73 | 73 |
74 bool NativeMediaFileUtil::PathExists( | |
75 FileSystemOperationContext* context, | |
76 const FileSystemURL& url) { | |
77 DCHECK(context); | |
78 | |
79 FilePath path; | |
80 PlatformFileInfo file_info; | |
81 PlatformFileError error = | |
82 GetFileInfo(context, url, &file_info, &path); | |
83 return error == base::PLATFORM_FILE_OK; | |
84 } | |
85 | |
86 bool NativeMediaFileUtil::IsDirectoryEmpty( | 74 bool NativeMediaFileUtil::IsDirectoryEmpty( |
87 FileSystemOperationContext* context, | 75 FileSystemOperationContext* context, |
88 const FileSystemURL& url) { | 76 const FileSystemURL& url) { |
89 DCHECK(context); | 77 DCHECK(context); |
90 DCHECK(context->media_path_filter()); | 78 DCHECK(context->media_path_filter()); |
91 | 79 |
92 scoped_ptr<AbstractFileEnumerator> enumerator( | 80 scoped_ptr<AbstractFileEnumerator> enumerator( |
93 CreateFileEnumerator(context, url, false)); | 81 CreateFileEnumerator(context, url, false)); |
94 FilePath path; | 82 FilePath path; |
95 while (!(path = enumerator->Next()).empty()) { | 83 while (!(path = enumerator->Next()).empty()) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (error != base::PLATFORM_FILE_OK) | 128 if (error != base::PLATFORM_FILE_OK) |
141 return error; | 129 return error; |
142 | 130 |
143 if (file_info->is_directory || | 131 if (file_info->is_directory || |
144 context->media_path_filter()->Match(*platform_path)) | 132 context->media_path_filter()->Match(*platform_path)) |
145 return base::PLATFORM_FILE_OK; | 133 return base::PLATFORM_FILE_OK; |
146 return base::PLATFORM_FILE_ERROR_NOT_FOUND; | 134 return base::PLATFORM_FILE_ERROR_NOT_FOUND; |
147 } | 135 } |
148 | 136 |
149 } // namespace fileapi | 137 } // namespace fileapi |
OLD | NEW |