OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * Joins paths so that the two paths are connected by only 1 '/'. | 6 * Joins paths so that the two paths are connected by only 1 '/'. |
7 * @param {string} a Path. | 7 * @param {string} a Path. |
8 * @param {string} b Path. | 8 * @param {string} b Path. |
9 * @return {string} Joined path. | 9 * @return {string} Joined path. |
10 */ | 10 */ |
(...skipping 27 matching lines...) Expand all Loading... | |
38 this.filesystem = filesystem; | 38 this.filesystem = filesystem; |
39 this.fullPath = fullPath; | 39 this.fullPath = fullPath; |
40 } | 40 } |
41 | 41 |
42 MockEntry.prototype = { | 42 MockEntry.prototype = { |
43 /** | 43 /** |
44 * @return {string} Name of the entry. | 44 * @return {string} Name of the entry. |
45 */ | 45 */ |
46 get name() { | 46 get name() { |
47 return this.fullPath.replace(/^.*\//, ''); | 47 return this.fullPath.replace(/^.*\//, ''); |
48 }, | |
49 get fileSystem() { | |
hirono
2014/10/24 07:12:21
Is it needed? We already have filesystem property.
yawano
2014/10/27 00:25:08
Sorry, this method was unnecessary. I deleted.
| |
50 return this.filesystem; | |
48 } | 51 } |
49 }; | 52 }; |
50 | 53 |
51 /** | 54 /** |
52 * Returns fake URL. | 55 * Returns fake URL. |
53 * | 56 * |
54 * @return {string} Fake URL. | 57 * @return {string} Fake URL. |
55 */ | 58 */ |
56 MockEntry.prototype.toURL = function() { | 59 MockEntry.prototype.toURL = function() { |
57 return 'filesystem:' + this.filesystem.fileSystemId + this.fullPath; | 60 if(this.filesystem.fileSystemId) { |
61 return 'filesystem:' + this.filesystem.fileSystemId + this.fullPath; | |
62 } else { | |
63 return 'filesystem:' + this.filesystem.name + this.fullPath; | |
64 } | |
58 }; | 65 }; |
59 | 66 |
60 /** | 67 /** |
61 * Obtains parent directory. | 68 * Obtains parent directory. |
62 * | 69 * |
63 * @param {function(MockDirectoryEntry)} onSuccess Callback invoked with | 70 * @param {function(MockDirectoryEntry)} onSuccess Callback invoked with |
64 * the parent directory. | 71 * the parent directory. |
65 * @param {function(Object)} onError Callback invoked with an error | 72 * @param {function(Object)} onError Callback invoked with an error |
66 * object. | 73 * object. |
67 */ | 74 */ |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 MockDirectoryEntry.prototype.getDirectory = | 212 MockDirectoryEntry.prototype.getDirectory = |
206 function(path, option, onSuccess, onError) { | 213 function(path, option, onSuccess, onError) { |
207 var fullPath = path[0] === '/' ? path : joinPath(this.fullPath, path); | 214 var fullPath = path[0] === '/' ? path : joinPath(this.fullPath, path); |
208 if (!this.filesystem.entries[fullPath]) | 215 if (!this.filesystem.entries[fullPath]) |
209 onError({name: util.FileError.NOT_FOUND_ERR}); | 216 onError({name: util.FileError.NOT_FOUND_ERR}); |
210 else if (!(this.filesystem.entries[fullPath] instanceof MockDirectoryEntry)) | 217 else if (!(this.filesystem.entries[fullPath] instanceof MockDirectoryEntry)) |
211 onError({name: util.FileError.TYPE_MISMATCH_ERR}); | 218 onError({name: util.FileError.TYPE_MISMATCH_ERR}); |
212 else | 219 else |
213 onSuccess(this.filesystem.entries[fullPath]); | 220 onSuccess(this.filesystem.entries[fullPath]); |
214 }; | 221 }; |
222 | |
223 /** | |
224 * Creates a MockDirectoryReader for the entry. | |
225 */ | |
226 MockDirectoryEntry.prototype.createReader = function() { | |
227 return new MockDirectoryReader(); | |
228 } | |
229 | |
230 /** | |
231 * Mock class for DirectoryReader. | |
232 */ | |
233 function MockDirectoryReader() {} | |
234 | |
235 /** | |
236 * Reads entries. | |
237 * Current implementation just calls success callback. | |
238 */ | |
239 MockDirectoryReader.prototype.readEntries = function(success, error) { | |
240 success(); | |
241 } | |
OLD | NEW |