Debian Codegraph @

closure-library/closure/goog/fs/entry.js

raw
1 // Copyright 2011 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview Wrappers for HTML5 Entry objects. These are all in the same
17 * file to avoid circular dependency issues.
18 *
19 * When adding or modifying functionality in this namespace, be sure to update
20 * the mock counterparts in goog.testing.fs.
21 *
22 */
23 goog.provide('goog.fs.DirectoryEntry');
24 goog.provide('goog.fs.DirectoryEntry.Behavior');
25 goog.provide('goog.fs.Entry');
26 goog.provide('goog.fs.FileEntry');
27
28
29
30 /**
31 * The interface for entries in the filesystem.
32 * @interface
33 */
34 goog.fs.Entry = function() {};
35
36
37 /**
38 * @return {boolean} Whether or not this entry is a file.
39 */
40 goog.fs.Entry.prototype.isFile = function() {};
41
42
43 /**
44 * @return {boolean} Whether or not this entry is a directory.
45 */
46 goog.fs.Entry.prototype.isDirectory = function() {};
47
48
49 /**
50 * @return {string} The name of this entry.
51 */
52 goog.fs.Entry.prototype.getName = function() {};
53
54
55 /**
56 * @return {string} The full path to this entry.
57 */
58 goog.fs.Entry.prototype.getFullPath = function() {};
59
60
61 /**
62 * @return {!goog.fs.FileSystem} The filesystem backing this entry.
63 */
64 goog.fs.Entry.prototype.getFileSystem = function() {};
65
66
67 /**
68 * Retrieves the last modified date for this entry.
69 *
70 * @return {!goog.async.Deferred} The deferred Date for this entry. If an error
71 * occurs, the errback is called with a {@link goog.fs.Error}.
72 */
73 goog.fs.Entry.prototype.getLastModified = function() {};
74
75
76 /**
77 * Retrieves the metadata for this entry.
78 *
79 * @return {!goog.async.Deferred} The deferred Metadata for this entry. If an
80 * error occurs, the errback is called with a {@link goog.fs.Error}.
81 */
82 goog.fs.Entry.prototype.getMetadata = function() {};
83
84
85 /**
86 * Move this entry to a new location.
87 *
88 * @param {!goog.fs.DirectoryEntry} parent The new parent directory.
89 * @param {string=} opt_newName The new name of the entry. If omitted, the entry
90 * retains its original name.
91 * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or
92 * {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the
93 * errback is called with a {@link goog.fs.Error}.
94 */
95 goog.fs.Entry.prototype.moveTo = function(parent, opt_newName) {};
96
97
98 /**
99 * Copy this entry to a new location.
100 *
101 * @param {!goog.fs.DirectoryEntry} parent The new parent directory.
102 * @param {string=} opt_newName The name of the new entry. If omitted, the new
103 * entry has the same name as the original.
104 * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry} or
105 * {@link goog.fs.DirectoryEntry} for the new entry. If an error occurs, the
106 * errback is called with a {@link goog.fs.Error}.
107 */
108 goog.fs.Entry.prototype.copyTo = function(parent, opt_newName) {};
109
110
111 /**
112 * Wrap an HTML5 entry object in an appropriate subclass instance.
113 *
114 * @param {!Entry} entry The underlying Entry object.
115 * @return {!goog.fs.Entry} The appropriate subclass wrapper.
116 * @protected
117 */
118 goog.fs.Entry.prototype.wrapEntry = function(entry) {};
119
120
121 /**
122 * Get the URL for this file.
123 *
124 * @param {string=} opt_mimeType The MIME type that will be served for the URL.
125 * @return {string} The URL.
126 */
127 goog.fs.Entry.prototype.toUrl = function(opt_mimeType) {};
128
129
130 /**
131 * Get the URI for this file.
132 *
133 * @deprecated Use {@link #toUrl} instead.
134 * @param {string=} opt_mimeType The MIME type that will be served for the URI.
135 * @return {string} The URI.
136 */
137 goog.fs.Entry.prototype.toUri = function(opt_mimeType) {};
138
139
140 /**
141 * Remove this entry.
142 *
143 * @return {!goog.async.Deferred} A deferred object. If the removal succeeds,
144 * the callback is called with true. If an error occurs, the errback is
145 * called a {@link goog.fs.Error}.
146 */
147 goog.fs.Entry.prototype.remove = function() {};
148
149
150 /**
151 * Gets the parent directory.
152 *
153 * @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.
154 * If an error occurs, the errback is called with a {@link goog.fs.Error}.
155 */
156 goog.fs.Entry.prototype.getParent = function() {};
157
158
159
160 /**
161 * A directory in a local FileSystem.
162 *
163 * @interface
164 * @extends {goog.fs.Entry}
165 */
166 goog.fs.DirectoryEntry = function() {};
167
168
169 /**
170 * Behaviors for getting files and directories.
171 * @enum {number}
172 */
173 goog.fs.DirectoryEntry.Behavior = {
174 /**
175 * Get the file if it exists, error out if it doesn't.
176 */
177 DEFAULT: 1,
178 /**
179 * Get the file if it exists, create it if it doesn't.
180 */
181 CREATE: 2,
182 /**
183 * Error out if the file exists, create it if it doesn't.
184 */
185 CREATE_EXCLUSIVE: 3
186 };
187
188
189 /**
190 * Get a file in the directory.
191 *
192 * @param {string} path The path to the file, relative to this directory.
193 * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
194 * handling an existing file, or the lack thereof.
195 * @return {!goog.async.Deferred} The deferred {@link goog.fs.FileEntry}. If an
196 * error occurs, the errback is called with a {@link goog.fs.Error}.
197 */
198 goog.fs.DirectoryEntry.prototype.getFile = function(path, opt_behavior) {};
199
200
201 /**
202 * Get a directory within this directory.
203 *
204 * @param {string} path The path to the directory, relative to this directory.
205 * @param {goog.fs.DirectoryEntry.Behavior=} opt_behavior The behavior for
206 * handling an existing directory, or the lack thereof.
207 * @return {!goog.async.Deferred} The deferred {@link goog.fs.DirectoryEntry}.
208 * If an error occurs, the errback is called a {@link goog.fs.Error}.
209 */
210 goog.fs.DirectoryEntry.prototype.getDirectory = function(path, opt_behavior) {};
211
212
213 /**
214 * Opens the directory for the specified path, creating the directory and any
215 * intermediate directories as necessary.
216 *
217 * @param {string} path The directory path to create. May be absolute or
218 * relative to the current directory. The parent directory ".." and current
219 * directory "." are supported.
220 * @return {!goog.async.Deferred} A deferred {@link goog.fs.DirectoryEntry} for
221 * the requested path. If an error occurs, the errback is called with a
222 * {@link goog.fs.Error}.
223 */
224 goog.fs.DirectoryEntry.prototype.createPath = function(path) {};
225
226
227 /**
228 * Gets a list of all entries in this directory.
229 *
230 * @return {!goog.async.Deferred} The deferred list of {@link goog.fs.Entry}
231 * results. If an error occurs, the errback is called with a
232 * {@link goog.fs.Error}.
233 */
234 goog.fs.DirectoryEntry.prototype.listDirectory = function() {};
235
236
237 /**
238 * Removes this directory and all its contents.
239 *
240 * @return {!goog.async.Deferred} A deferred object. If the removal succeeds,
241 * the callback is called with true. If an error occurs, the errback is
242 * called a {@link goog.fs.Error}.
243 */
244 goog.fs.DirectoryEntry.prototype.removeRecursively = function() {};
245
246
247
248 /**
249 * A file in a local filesystem.
250 *
251 * @interface
252 * @extends {goog.fs.Entry}
253 */
254 goog.fs.FileEntry = function() {};
255
256
257 /**
258 * Create a writer for writing to the file.
259 *
260 * @return {!goog.async.Deferred<!goog.fs.FileWriter>} If an error occurs, the
261 * errback is called with a {@link goog.fs.Error}.
262 */
263 goog.fs.FileEntry.prototype.createWriter = function() {};
264
265
266 /**
267 * Get the file contents as a File blob.
268 *
269 * @return {!goog.async.Deferred<!File>} If an error occurs, the errback is
270 * called with a {@link goog.fs.Error}.
271 */
272 goog.fs.FileEntry.prototype.file = function() {};