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/isolated_file_util.h" | 5 #include "webkit/fileapi/isolated_file_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 private: | 51 private: |
52 std::vector<FileInfo> files_; | 52 std::vector<FileInfo> files_; |
53 std::vector<FileInfo>::const_iterator file_iter_; | 53 std::vector<FileInfo>::const_iterator file_iter_; |
54 base::PlatformFileInfo file_info_; | 54 base::PlatformFileInfo file_info_; |
55 }; | 55 }; |
56 | 56 |
57 // Recursively enumerate each path from a given paths set. | 57 // Recursively enumerate each path from a given paths set. |
58 class RecursiveSetFileEnumerator | 58 class RecursiveSetFileEnumerator |
59 : public FileSystemFileUtil::AbstractFileEnumerator { | 59 : public FileSystemFileUtil::AbstractFileEnumerator { |
60 public: | 60 public: |
61 RecursiveSetFileEnumerator(const std::vector<FileInfo>& files) | 61 explicit RecursiveSetFileEnumerator(const std::vector<FileInfo>& files) |
62 : files_(files) { | 62 : files_(files) { |
63 file_iter_ = files_.begin(); | 63 file_iter_ = files_.begin(); |
64 current_enumerator_.reset(new SetFileEnumerator(files)); | 64 current_enumerator_.reset(new SetFileEnumerator(files)); |
65 } | 65 } |
66 virtual ~RecursiveSetFileEnumerator() {} | 66 virtual ~RecursiveSetFileEnumerator() {} |
67 | 67 |
68 // AbstractFileEnumerator overrides. | 68 // AbstractFileEnumerator overrides. |
69 virtual FilePath Next() OVERRIDE; | 69 virtual FilePath Next() OVERRIDE; |
70 virtual int64 Size() OVERRIDE { | 70 virtual int64 Size() OVERRIDE { |
71 DCHECK(current_enumerator_.get()); | 71 DCHECK(current_enumerator_.get()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 // Root path case. | 170 // Root path case. |
171 std::vector<FileInfo> toplevels; | 171 std::vector<FileInfo> toplevels; |
172 IsolatedContext::GetInstance()->GetDraggedFileInfo( | 172 IsolatedContext::GetInstance()->GetDraggedFileInfo( |
173 root.filesystem_id(), &toplevels); | 173 root.filesystem_id(), &toplevels); |
174 if (!recursive) | 174 if (!recursive) |
175 return new SetFileEnumerator(toplevels); | 175 return new SetFileEnumerator(toplevels); |
176 return new RecursiveSetFileEnumerator(toplevels); | 176 return new RecursiveSetFileEnumerator(toplevels); |
177 } | 177 } |
178 | 178 |
179 bool DraggedFileUtil::PathExists( | |
180 FileSystemOperationContext* context, | |
181 const FileSystemURL& url) { | |
182 if (url.path().empty()) { | |
183 // The root directory case. | |
184 return true; | |
185 } | |
186 return NativeFileUtil::PathExists(url.path()); | |
187 } | |
188 | |
189 bool DraggedFileUtil::DirectoryExists( | |
190 FileSystemOperationContext* context, | |
191 const FileSystemURL& url) { | |
192 if (url.path().empty()) { | |
193 // The root directory case. | |
194 return true; | |
195 } | |
196 return NativeFileUtil::DirectoryExists(url.path()); | |
197 } | |
198 | |
199 bool DraggedFileUtil::IsDirectoryEmpty( | 179 bool DraggedFileUtil::IsDirectoryEmpty( |
200 FileSystemOperationContext* context, | 180 FileSystemOperationContext* context, |
201 const FileSystemURL& url) { | 181 const FileSystemURL& url) { |
202 if (url.path().empty()) { | 182 if (url.path().empty()) { |
203 // The root directory case. | 183 // The root directory case. |
204 std::vector<FileInfo> toplevels; | 184 std::vector<FileInfo> toplevels; |
205 bool success = IsolatedContext::GetInstance()->GetDraggedFileInfo( | 185 bool success = IsolatedContext::GetInstance()->GetDraggedFileInfo( |
206 url.filesystem_id(), &toplevels); | 186 url.filesystem_id(), &toplevels); |
207 DCHECK(success); | 187 DCHECK(success); |
208 return toplevels.empty(); | 188 return toplevels.empty(); |
209 } | 189 } |
210 return NativeFileUtil::IsDirectoryEmpty(url.path()); | 190 return NativeFileUtil::IsDirectoryEmpty(url.path()); |
211 } | 191 } |
212 | 192 |
213 } // namespace | 193 } // namespace |
OLD | NEW |