1 | /** This interface represents a file system. */
|
2 | export interface FileSystem {
|
3 | name: string;
|
4 | /** The root directory of the file system. */
|
5 | root: DirectoryEntry;
|
6 | }
|
7 | /**
|
8 | * An abstract interface representing entries in a file system,
|
9 | * each of which may be a File or DirectoryEntry.
|
10 | */
|
11 | export interface Entry {
|
12 | /** Entry is a file. */
|
13 | isFile: boolean;
|
14 | /** Entry is a directory. */
|
15 | isDirectory: boolean;
|
16 | /** The name of the entry, excluding the path leading to it. */
|
17 | name: string;
|
18 | /** The full absolute path from the root to the entry. */
|
19 | fullPath: string;
|
20 | /** The file system on which the entry resides. */
|
21 | filesystem: FileSystem;
|
22 | nativeURL: string;
|
23 | /**
|
24 | * Look up metadata about this entry.
|
25 | * @param successCallback A callback that is called with the time of the last modification.
|
26 | * @param errorCallback A callback that is called when errors happen.
|
27 | */
|
28 | getMetadata(successCallback: (metadata: Metadata) => void, errorCallback?: (error: FileError) => void): void;
|
29 | /**
|
30 | * Move an entry to a different location on the file system. It is an error to try to:
|
31 | * move a directory inside itself or to any child at any depth;move an entry into its parent if a name different from its current one isn't provided;
|
32 | * move a file to a path occupied by a directory;
|
33 | * move a directory to a path occupied by a file;
|
34 | * move any element to a path occupied by a directory which is not empty.
|
35 | * A move of a file on top of an existing file must attempt to delete and replace that file.
|
36 | * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
37 | * @param parent The directory to which to move the entry.
|
38 | * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
|
39 | * @param successCallback A callback that is called with the Entry for the new location.
|
40 | * @param errorCallback A callback that is called when errors happen.
|
41 | */
|
42 | moveTo(parent: DirectoryEntry, newName?: string, successCallback?: (entry: Entry) => void, errorCallback?: (error: FileError) => void): void;
|
43 | /**
|
44 | * Copy an entry to a different location on the file system. It is an error to try to:
|
45 | * copy a directory inside itself or to any child at any depth;
|
46 | * copy an entry into its parent if a name different from its current one isn't provided;
|
47 | * copy a file to a path occupied by a directory;
|
48 | * copy a directory to a path occupied by a file;
|
49 | * copy any element to a path occupied by a directory which is not empty.
|
50 | * A copy of a file on top of an existing file must attempt to delete and replace that file.
|
51 | * A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
|
52 | * Directory copies are always recursive--that is, they copy all contents of the directory.
|
53 | * @param parent The directory to which to move the entry.
|
54 | * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
|
55 | * @param successCallback A callback that is called with the Entry for the new object.
|
56 | * @param errorCallback A callback that is called when errors happen.
|
57 | */
|
58 | copyTo(parent: DirectoryEntry, newName?: string, successCallback?: (entry: Entry) => void, errorCallback?: (error: FileError) => void): void;
|
59 | /**
|
60 | * Returns a URL that can be used as the src attribute of a <video> or <audio> tag.
|
61 | * If that is not possible, construct a cdvfile:// URL.
|
62 | * @return string URL
|
63 | */
|
64 | toURL(): string;
|
65 | /**
|
66 | * Return a URL that can be passed across the bridge to identify this entry.
|
67 | * @return string URL that can be passed across the bridge to identify this entry
|
68 | */
|
69 | toInternalURL(): string;
|
70 | /**
|
71 | * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
|
72 | * @param successCallback A callback that is called on success.
|
73 | * @param errorCallback A callback that is called when errors happen.
|
74 | */
|
75 | remove(successCallback: () => void, errorCallback?: (error: FileError) => void): void;
|
76 | /**
|
77 | * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
|
78 | * @param successCallback A callback that is called with the time of the last modification.
|
79 | * @param errorCallback A callback that is called when errors happen.
|
80 | */
|
81 | getParent(successCallback: (entry: Entry) => void, errorCallback?: (error: FileError) => void): void;
|
82 | }
|
83 | /** This interface supplies information about the state of a file or directory. */
|
84 | export interface Metadata {
|
85 | /** This is the time at which the file or directory was last modified. */
|
86 | modificationTime: Date;
|
87 | /** The size of the file, in bytes. This must return 0 for directories. */
|
88 | size: number;
|
89 | }
|
90 | /** This interface represents a directory on a file system. */
|
91 | export interface DirectoryEntry extends Entry {
|
92 | /**
|
93 | * Creates a new DirectoryReader to read Entries from this Directory.
|
94 | */
|
95 | createReader(): DirectoryReader;
|
96 | /**
|
97 | * Creates or looks up a file.
|
98 | * @param path Either an absolute path or a relative path from this DirectoryEntry
|
99 | * to the file to be looked up or created.
|
100 | * It is an error to attempt to create a file whose immediate parent does not yet exist.
|
101 | * @param options If create and exclusive are both true, and the path already exists, getFile must fail.
|
102 | * If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
|
103 | * If create is not true and the path doesn't exist, getFile must fail.
|
104 | * If create is not true and the path exists, but is a directory, getFile must fail.
|
105 | * Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
|
106 | * @param successCallback A callback that is called to return the File selected or created.
|
107 | * @param errorCallback A callback that is called when errors happen.
|
108 | */
|
109 | getFile(path: string, options?: Flags, successCallback?: (entry: FileEntry) => void, errorCallback?: (error: FileError) => void): void;
|
110 | /**
|
111 | * Creates or looks up a directory.
|
112 | * @param path Either an absolute path or a relative path from this DirectoryEntry
|
113 | * to the directory to be looked up or created.
|
114 | * It is an error to attempt to create a directory whose immediate parent does not yet exist.
|
115 | * @param options If create and exclusive are both true and the path already exists, getDirectory must fail.
|
116 | * If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
|
117 | * If create is not true and the path doesn't exist, getDirectory must fail.
|
118 | * If create is not true and the path exists, but is a file, getDirectory must fail.
|
119 | * Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
|
120 | * @param successCallback A callback that is called to return the Directory selected or created.
|
121 | * @param errorCallback A callback that is called when errors happen.
|
122 | */
|
123 | getDirectory(path: string, options?: Flags, successCallback?: (entry: DirectoryEntry) => void, errorCallback?: (error: FileError) => void): void;
|
124 | /**
|
125 | * Deletes a directory and all of its contents, if any. In the event of an error (e.g. trying
|
126 | * to delete a directory that contains a file that cannot be removed), some of the contents
|
127 | * of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
|
128 | * @param successCallback A callback that is called on success.
|
129 | * @param errorCallback A callback that is called when errors happen.
|
130 | */
|
131 | removeRecursively(successCallback: () => void, errorCallback?: (error: FileError) => void): void;
|
132 | }
|
133 | export interface RemoveResult {
|
134 | success: boolean;
|
135 | fileRemoved: Entry;
|
136 | }
|
137 | /**
|
138 | * This dictionary is used to supply arguments to methods
|
139 | * that look up or create files or directories.
|
140 | */
|
141 | export interface Flags {
|
142 | /** Used to indicate that the user wants to create a file or directory if it was not previously there. */
|
143 | create?: boolean;
|
144 | /** By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. */
|
145 | exclusive?: boolean;
|
146 | }
|
147 | export interface WriteOptions {
|
148 | replace?: boolean;
|
149 | append?: boolean;
|
150 | truncate?: number;
|
151 | }
|
152 | /**
|
153 | * This interface lets a user list files and directories in a directory. If there are
|
154 | * no additions to or deletions from a directory between the first and last call to
|
155 | * readEntries, and no errors occur, then:
|
156 | * A series of calls to readEntries must return each entry in the directory exactly once.
|
157 | * Once all entries have been returned, the next call to readEntries must produce an empty array.
|
158 | * If not all entries have been returned, the array produced by readEntries must not be empty.
|
159 | * The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
|
160 | */
|
161 | export interface DirectoryReader {
|
162 | /**
|
163 | * Read the next block of entries from this directory.
|
164 | * @param successCallback Called once per successful call to readEntries to deliver the next
|
165 | * previously-unreported set of Entries in the associated Directory.
|
166 | * If all Entries have already been returned from previous invocations
|
167 | * of readEntries, successCallback must be called with a zero-length array as an argument.
|
168 | * @param errorCallback A callback indicating that there was an error reading from the Directory.
|
169 | */
|
170 | readEntries(successCallback: (entries: Entry[]) => void, errorCallback?: (error: FileError) => void): void;
|
171 | }
|
172 | /** This interface represents a file on a file system. */
|
173 | export interface FileEntry extends Entry {
|
174 | /**
|
175 | * Creates a new FileWriter associated with the file that this FileEntry represents.
|
176 | * @param successCallback A callback that is called with the new FileWriter.
|
177 | * @param errorCallback A callback that is called when errors happen.
|
178 | */
|
179 | createWriter(successCallback: (writer: FileWriter) => void, errorCallback?: (error: FileError) => void): void;
|
180 | /**
|
181 | * Returns a File that represents the current state of the file that this FileEntry represents.
|
182 | * @param successCallback A callback that is called with the File.
|
183 | * @param errorCallback A callback that is called when errors happen.
|
184 | */
|
185 | file(successCallback: (file: File) => void, errorCallback?: (error: FileError) => void): void;
|
186 | }
|
187 | /**
|
188 | * This interface provides methods to monitor the asynchronous writing of blobs
|
189 | * to disk using progress events and event handler attributes.
|
190 | */
|
191 | export interface FileSaver extends EventTarget {
|
192 | /** Terminate file operation */
|
193 | abort(): void;
|
194 | /**
|
195 | * The FileSaver object can be in one of 3 states. The readyState attribute, on getting,
|
196 | * must return the current state, which must be one of the following values:
|
197 | * INIT
|
198 | * WRITING
|
199 | * DONE
|
200 | */
|
201 | readyState: number;
|
202 | /** Handler for writestart events. */
|
203 | onwritestart: (event: ProgressEvent) => void;
|
204 | /** Handler for progress events. */
|
205 | onprogress: (event: ProgressEvent) => void;
|
206 | /** Handler for write events. */
|
207 | onwrite: (event: ProgressEvent) => void;
|
208 | /** Handler for abort events. */
|
209 | onabort: (event: ProgressEvent) => void;
|
210 | /** Handler for error events. */
|
211 | onerror: (event: ProgressEvent) => void;
|
212 | /** Handler for writeend events. */
|
213 | onwriteend: (event: ProgressEvent) => void;
|
214 | /** The last error that occurred on the FileSaver. */
|
215 | error: Error;
|
216 | }
|
217 | /**
|
218 | * This interface expands on the FileSaver interface to allow for multiple write
|
219 | * actions, rather than just saving a single Blob.
|
220 | */
|
221 | export interface FileWriter extends FileSaver {
|
222 | /**
|
223 | * The byte offset at which the next write to the file will occur. This always less or equal than length.
|
224 | * A newly-created FileWriter will have position set to 0.
|
225 | */
|
226 | position: number;
|
227 | /**
|
228 | * The length of the file. If the user does not have read access to the file,
|
229 | * this will be the highest byte offset at which the user has written.
|
230 | */
|
231 | length: number;
|
232 | /**
|
233 | * Write the supplied data to the file at position.
|
234 | * @param {Blob} data The blob to write.
|
235 | */
|
236 | write(data: ArrayBuffer | Blob | string): void;
|
237 | /**
|
238 | * The file position at which the next write will occur.
|
239 | * @param offset If nonnegative, an absolute byte offset into the file.
|
240 | * If negative, an offset back from the end of the file.
|
241 | */
|
242 | seek(offset: number): void;
|
243 | /**
|
244 | * Changes the length of the file to that specified. If shortening the file, data beyond the new length
|
245 | * will be discarded. If extending the file, the existing data will be zero-padded up to the new length.
|
246 | * @param size The size to which the length of the file is to be adjusted, measured in bytes.
|
247 | */
|
248 | truncate(size: number): void;
|
249 | }
|
250 | export declare var FileWriter: {
|
251 | INIT: number;
|
252 | WRITING: number;
|
253 | DONE: number;
|
254 | };
|
255 | export interface FileReader {
|
256 | readyState: number;
|
257 | error: Error;
|
258 | result: string | ArrayBuffer;
|
259 | onloadstart: (evt: ProgressEvent) => void;
|
260 | onprogress: (evt: ProgressEvent) => void;
|
261 | onload: (evt: ProgressEvent) => void;
|
262 | onerror: (evt: ProgressEvent) => void;
|
263 | onloadend: (evt: ProgressEvent) => void;
|
264 | onabort: (evt: ProgressEvent) => void;
|
265 | abort(): void;
|
266 | readAsText(fe: File | Blob, encoding?: string): void;
|
267 | readAsDataURL(fe: File | Blob): void;
|
268 | readAsBinaryString(fe: File | Blob): void;
|
269 | readAsArrayBuffer(fe: File | Blob): void;
|
270 | }
|
271 | export declare var FileReader: {
|
272 | EMPTY: number;
|
273 | LOADING: number;
|
274 | DONE: number;
|
275 | new (): FileReader;
|
276 | };
|
277 | export interface FileError {
|
278 | /** Error code */
|
279 | code: number;
|
280 | message: string;
|
281 | }
|
282 | export declare var FileError: {
|
283 | new (code: number): FileError;
|
284 | NOT_FOUND_ERR: number;
|
285 | SECURITY_ERR: number;
|
286 | ABORT_ERR: number;
|
287 | NOT_READABLE_ERR: number;
|
288 | ENCODING_ERR: number;
|
289 | NO_MODIFICATION_ALLOWED_ERR: number;
|
290 | INVALID_STATE_ERR: number;
|
291 | SYNTAX_ERR: number;
|
292 | INVALID_MODIFICATION_ERR: number;
|
293 | QUOTA_EXCEEDED_ERR: number;
|
294 | TYPE_MISMATCH_ERR: number;
|
295 | PATH_EXISTS_ERR: number;
|
296 | };
|
297 | /**
|
298 | * @name File
|
299 | * @description
|
300 | * This plugin implements a File API allowing read/write access to files residing on the device.
|
301 | *
|
302 | * The File class implements static convenience functions to access files and directories.
|
303 | *
|
304 | * Example:
|
305 | * ```
|
306 | * import { File } from 'ionic-native';
|
307 | *
|
308 | * const dataDirectory: string = File.dataDirectory;
|
309 | *
|
310 | * File.checkDir(dataDirectory, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh'));
|
311 | * ```
|
312 | *
|
313 | * This plugin is based on several specs, including : The HTML5 File API http://www.w3.org/TR/FileAPI/
|
314 | * The (now-defunct) Directories and System extensions Latest: http://www.w3.org/TR/2012/WD-file-system-api-20120417/
|
315 | * Although most of the plugin code was written when an earlier spec was current: http://www.w3.org/TR/2011/WD-file-system-api-20110419/
|
316 | * It also implements the FileWriter spec : http://dev.w3.org/2009/dap/file-system/file-writer.html
|
317 | */
|
318 | export declare class File {
|
319 | /**
|
320 | * Read-only directory where the application is installed.
|
321 | */
|
322 | static applicationDirectory: string;
|
323 | /**
|
324 | * Read-only directory where the application is installed.
|
325 | */
|
326 | static applicationStorageDirectory: string;
|
327 | /**
|
328 | * Where to put app-specific data files.
|
329 | */
|
330 | static dataDirectory: string;
|
331 | /**
|
332 | * Cached files that should survive app restarts.
|
333 | * Apps should not rely on the OS to delete files in here.
|
334 | */
|
335 | static cacheDirectory: string;
|
336 | /**
|
337 | * Android: the application space on external storage.
|
338 | */
|
339 | static externalApplicationStorageDirectory: string;
|
340 | /**
|
341 | * Android: Where to put app-specific data files on external storage.
|
342 | */
|
343 | static externalDataDirectory: string;
|
344 | /**
|
345 | * Android: the application cache on external storage.
|
346 | */
|
347 | static externalCacheDirectory: string;
|
348 | /**
|
349 | * Android: the external storage (SD card) root.
|
350 | */
|
351 | static externalRootDirectory: string;
|
352 | /**
|
353 | * iOS: Temp directory that the OS can clear at will.
|
354 | */
|
355 | static tempDirectory: string;
|
356 | /**
|
357 | * iOS: Holds app-specific files that should be synced (e.g. to iCloud).
|
358 | */
|
359 | static syncedDataDirectory: string;
|
360 | /**
|
361 | * iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
|
362 | */
|
363 | static documentsDirectory: string;
|
364 | /**
|
365 | * BlackBerry10: Files globally available to all apps
|
366 | */
|
367 | static sharedDirectory: string;
|
368 | static cordovaFileError: {};
|
369 | /**
|
370 | * Get free disk space in Bytes
|
371 | * @returns {Promise<number>} Returns a promise that resolves with the remaining free disk space in Bytes
|
372 | */
|
373 | static getFreeDiskSpace(): Promise<number>;
|
374 | /**
|
375 | * Check if a directory exists in a certain path, directory.
|
376 | *
|
377 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
378 | * @param {string} dir Name of directory to check
|
379 | * @returns {Promise<boolean>} Returns a Promise that resolves to true if the directory exists or rejects with an error.
|
380 | */
|
381 | static checkDir(path: string, dir: string): Promise<boolean>;
|
382 | /**
|
383 | * Creates a new directory in the specific path.
|
384 | * The replace boolean value determines whether to replace an existing directory with the same name.
|
385 | * If an existing directory exists and the replace value is false, the promise will fail and return an error.
|
386 | *
|
387 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
388 | * @param {string} dirName Name of directory to create
|
389 | * @param {boolean} replace If true, replaces file with same name. If false returns error
|
390 | * @returns {Promise<DirectoryEntry>} Returns a Promise that resolves with a DirectoryEntry or rejects with an error.
|
391 | */
|
392 | static createDir(path: string, dirName: string, replace: boolean): Promise<DirectoryEntry>;
|
393 | /**
|
394 | * Remove a directory at a given path.
|
395 | *
|
396 | * @param {string} path The path to the directory
|
397 | * @param {string} dirName The directory name
|
398 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
|
399 | */
|
400 | static removeDir(path: string, dirName: string): Promise<RemoveResult>;
|
401 | /**
|
402 | * Move a directory to a given path.
|
403 | *
|
404 | * @param {string} path The source path to the directory
|
405 | * @param {string} dirName The source directory name
|
406 | * @param {string} newPath The destionation path to the directory
|
407 | * @param {string} newDirName The destination directory name
|
408 | * @returns {Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or rejects with an error.
|
409 | */
|
410 | static moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<DirectoryEntry | Entry>;
|
411 | /**
|
412 | * Copy a directory in various methods. If destination directory exists, will fail to copy.
|
413 | *
|
414 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
415 | * @param {string} dirName Name of directory to copy
|
416 | * @param {string} newPath Base FileSystem of new location
|
417 | * @param {string} newDirName New name of directory to copy to (leave blank to remain the same)
|
418 | * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry object or rejects with an error.
|
419 | */
|
420 | static copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<Entry>;
|
421 | /**
|
422 | * List files and directory from a given path.
|
423 | *
|
424 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
425 | * @param {string} dirName Name of directory
|
426 | * @returns {Promise<Entry[]>} Returns a Promise that resolves to an array of Entry objects or rejects with an error.
|
427 | */
|
428 | static listDir(path: string, dirName: string): Promise<Entry[]>;
|
429 | /**
|
430 | * Removes all files and the directory from a desired location.
|
431 | *
|
432 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
433 | * @param {string} dirName Name of directory
|
434 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves with a RemoveResult or rejects with an error.
|
435 | */
|
436 | static removeRecursively(path: string, dirName: string): Promise<RemoveResult>;
|
437 | /**
|
438 | * Check if a file exists in a certain path, directory.
|
439 | *
|
440 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
441 | * @param {string} file Name of file to check
|
442 | * @returns {Promise<boolean>} Returns a Promise that resolves with a boolean or rejects with an error.
|
443 | */
|
444 | static checkFile(path: string, file: string): Promise<boolean>;
|
445 | /**
|
446 | * Creates a new file in the specific path.
|
447 | * The replace boolean value determines whether to replace an existing file with the same name.
|
448 | * If an existing file exists and the replace value is false, the promise will fail and return an error.
|
449 | *
|
450 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
451 | * @param {string} fileName Name of file to create
|
452 | * @param {boolean} replace If true, replaces file with same name. If false returns error
|
453 | * @returns {Promise<FileEntry>} Returns a Promise that resolves to a FileEntry or rejects with an error.
|
454 | */
|
455 | static createFile(path: string, fileName: string, replace: boolean): Promise<FileEntry>;
|
456 | /**
|
457 | * Removes a file from a desired location.
|
458 | *
|
459 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
460 | * @param {string} fileName Name of file to remove
|
461 | * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
|
462 | */
|
463 | static removeFile(path: string, fileName: string): Promise<RemoveResult>;
|
464 | /** Write a new file to the desired location.
|
465 | *
|
466 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
467 | * @param {string} fileName path relative to base path
|
468 | * @param {string | Blob} text content or blob to write
|
469 | * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information.
|
470 | * @returns {Promise<any>} Returns a Promise that resolves to updated file entry or rejects with an error.
|
471 | */
|
472 | static writeFile(path: string, fileName: string, text: string | Blob | ArrayBuffer, options?: WriteOptions): Promise<any>;
|
473 | /** Write content to FileEntry.
|
474 | *
|
475 | * @private
|
476 | * @param {FileEntry} fe file entry object
|
477 | * @param {string | Blob} text content or blob to write
|
478 | * @param {WriteOptions} options replace file if set to true. See WriteOptions for more information.
|
479 | * @returns {Promise<FileEntry>} Returns a Promise that resolves to updated file entry or rejects with an error.
|
480 | */
|
481 | private static writeFileEntry(fe, text, options);
|
482 | /** Write to an existing file.
|
483 | *
|
484 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
485 | * @param {string} fileName path relative to base path
|
486 | * @param {string | Blob} text content or blob to write
|
487 | * @returns {Promise<void>} Returns a Promise that resolves or rejects with an error.
|
488 | */
|
489 | static writeExistingFile(path: string, fileName: string, text: string | Blob): Promise<void>;
|
490 | /**
|
491 | * Read the contents of a file as text.
|
492 | *
|
493 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
494 | * @param {string} file Name of file, relative to path.
|
495 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string or rejects with an error.
|
496 | */
|
497 | static readAsText(path: string, file: string): Promise<string>;
|
498 | /**
|
499 | * Read file and return data as a base64 encoded data url.
|
500 | * A data url is of the form:
|
501 | * data:[<mediatype>][;base64],<data>
|
502 |
|
503 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
504 | * @param {string} file Name of file, relative to path.
|
505 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as data URL or rejects with an error.
|
506 | */
|
507 | static readAsDataURL(path: string, file: string): Promise<string>;
|
508 | /**
|
509 | * Read file and return data as a binary data.
|
510 |
|
511 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
512 | * @param {string} file Name of file, relative to path.
|
513 | * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string rejects with an error.
|
514 | */
|
515 | static readAsBinaryString(path: string, file: string): Promise<string>;
|
516 | /**
|
517 | * Read file and return data as an ArrayBuffer.
|
518 |
|
519 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
520 | * @param {string} file Name of file, relative to path.
|
521 | * @returns {Promise<ArrayBuffer>} Returns a Promise that resolves with the contents of the file as ArrayBuffer or rejects with an error.
|
522 | */
|
523 | static readAsArrayBuffer(path: string, file: string): Promise<ArrayBuffer>;
|
524 | /**
|
525 | * Move a file to a given path.
|
526 | *
|
527 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
528 | * @param {string} fileName Name of file to move
|
529 | * @param {string} newPath Base FileSystem of new location
|
530 | * @param {string} newFileName New name of file to move to (leave blank to remain the same)
|
531 | * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry or rejects with an error.
|
532 | */
|
533 | static moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
|
534 | /**
|
535 | * Copy a file in various methods. If file exists, will fail to copy.
|
536 | *
|
537 | * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
|
538 | * @param {string} fileName Name of file to copy
|
539 | * @param {string} newPath Base FileSystem of new location
|
540 | * @param {string} newFileName New name of file to copy to (leave blank to remain the same)
|
541 | * @returns {Promise<Entry>} Returns a Promise that resolves to an Entry or rejects with an error.
|
542 | */
|
543 | static copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
|
544 | /**
|
545 | * @private
|
546 | */
|
547 | private static fillErrorMessage(err);
|
548 | /**
|
549 | * Resolves a local file system URL
|
550 | * @param fileUrl {string} file system url
|
551 | * @returns {Promise<Entry>}
|
552 | */
|
553 | static resolveLocalFilesystemUrl(fileUrl: string): Promise<Entry>;
|
554 | /**
|
555 | * Resolves a local directory url
|
556 | * @param directoryUrl {string} directory system url
|
557 | * @returns {Promise<DirectoryEntry>}
|
558 | */
|
559 | static resolveDirectoryUrl(directoryUrl: string): Promise<DirectoryEntry>;
|
560 | /**
|
561 | * Get a directory
|
562 | * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
|
563 | * @param directoryName {string} Directory name
|
564 | * @param flags {Flags} Options
|
565 | * @returns {Promise<DirectoryEntry>}
|
566 | */
|
567 | static getDirectory(directoryEntry: DirectoryEntry, directoryName: string, flags: Flags): Promise<DirectoryEntry>;
|
568 | /**
|
569 | * Get a file
|
570 | * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
|
571 | * @param fileName {string} File name
|
572 | * @param flags {Flags} Options
|
573 | * @returns {Promise<FileEntry>}
|
574 | */
|
575 | static getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise<FileEntry>;
|
576 | /**
|
577 | * @private
|
578 | */
|
579 | private static remove(fe);
|
580 | /**
|
581 | * @private
|
582 | */
|
583 | private static move(srce, destdir, newName);
|
584 | /**
|
585 | * @private
|
586 | */
|
587 | private static copy(srce, destdir, newName);
|
588 | /**
|
589 | * @private
|
590 | */
|
591 | private static readEntries(dr);
|
592 | /**
|
593 | * @private
|
594 | */
|
595 | private static rimraf(de);
|
596 | /**
|
597 | * @private
|
598 | */
|
599 | private static createWriter(fe);
|
600 | /**
|
601 | * @private
|
602 | */
|
603 | private static write(writer, gu);
|
604 | /**
|
605 | * @private
|
606 | */
|
607 | private static writeFileInChunks(writer, file);
|
608 | }
|