UNPKG

36.8 kBTypeScriptView Raw
1import { IonicNativePlugin } from '@ionic-native/core';
2export interface IFile extends Blob {
3 /**
4 * Name of the file, without path information
5 */
6 name: string;
7 /**
8 * Last modified date
9 */
10 lastModified: number;
11 /**
12 * Last modified date
13 */
14 lastModifiedDate: number;
15 /**
16 * Size in bytes
17 */
18 size: number;
19 /**
20 * File mime type
21 */
22 type: string;
23 localURL: string;
24 start: number;
25 end: number;
26 /**
27 * Returns a "slice" of the file. Since Cordova Files don't contain the actual
28 * content, this really returns a File with adjusted start and end.
29 * Slices of slices are supported.
30 * @param start {Number} The index at which to start the slice (inclusive).
31 * @param end {Number} The index at which to end the slice (exclusive).
32 */
33 slice(start: number, end: number): Blob;
34}
35export interface LocalFileSystem {
36 /**
37 * Used for storage with no guarantee of persistence.
38 */
39 TEMPORARY: number;
40 /**
41 * Used for storage that should not be removed by the user agent without application or user permission.
42 */
43 PERSISTENT: number;
44 /**
45 * Requests a filesystem in which to store application data.
46 * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or
47 * PERSISTENT.
48 * @param size This is an indicator of how much storage space, in bytes, the application expects to need.
49 * @param successCallback The callback that is called when the user agent provides a filesystem.
50 * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is
51 * denied.
52 */
53 requestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
54 /**
55 * Allows the user to look up the Entry for a file or directory referred to by a local URL.
56 * @param url A URL referring to a local file in a filesystem accessable via this API.
57 * @param successCallback A callback that is called to report the FileEntry to which the supplied URL refers.
58 * @param errorCallback A callback that is called when errors happen, or when the request to obtain the Entry is
59 * denied.
60 */
61 resolveLocalFileSystemURL(url: string, successCallback: FileEntryCallback, errorCallback?: ErrorCallback): void;
62 /**
63 * see requestFileSystem.
64 */
65 webkitRequestFileSystem(type: number, size: number, successCallback: FileSystemCallback, errorCallback?: ErrorCallback): void;
66}
67export interface Metadata {
68 /**
69 * This is the time at which the file or directory was last modified.
70 * @readonly
71 */
72 modificationTime: Date;
73 /**
74 * The size of the file, in bytes. This must return 0 for directories.
75 * @readonly
76 */
77 size: number;
78}
79export interface Flags {
80 /**
81 * Used to indicate that the user wants to create a file or directory if it was not previously there.
82 */
83 create?: boolean;
84 /**
85 * By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the
86 * target path already exists.
87 */
88 exclusive?: boolean;
89}
90/**
91 * This export interface represents a file system.
92 */
93export interface FileSystem {
94 /**
95 * This is the name of the file system. The specifics of naming filesystems is unspecified, but a name must be unique
96 * across the list of exposed file systems.
97 * @readonly
98 */
99 name: string;
100 /**
101 * The root directory of the file system.
102 * @readonly
103 */
104 root: DirectoryEntry;
105 toJSON(): string;
106 encodeURIPath(path: string): string;
107}
108export interface Entry {
109 /**
110 * Entry is a file.
111 */
112 isFile: boolean;
113 /**
114 * Entry is a directory.
115 */
116 isDirectory: boolean;
117 /**
118 * Look up metadata about this entry.
119 * @param successCallback A callback that is called with the time of the last modification.
120 * @param errorCallback ErrorCallback A callback that is called when errors happen.
121 */
122 getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;
123 /**
124 * Set the metadata of the entry.
125 * @param successCallback {Function} is called with a Metadata object
126 * @param errorCallback {Function} is called with a FileError
127 * @param metadataObject {Metadata} keys and values to set
128 */
129 setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): void;
130 /**
131 * The name of the entry, excluding the path leading to it.
132 */
133 name: string;
134 /**
135 * The full absolute path from the root to the entry.
136 */
137 fullPath: string;
138 /**
139 * The file system on which the entry resides.
140 */
141 filesystem: FileSystem;
142 /**
143 * an alternate URL which can be used by native webview controls, for example media players.
144 */
145 nativeURL: string;
146 /**
147 * Look up metadata about this entry.
148 * @param successCallback A callback that is called with the time of the last modification.
149 * @param errorCallback ErrorCallback A callback that is called when errors happen.
150 */
151 getMetadata(successCallback: MetadataCallback, errorCallback?: ErrorCallback): void;
152 /**
153 * Set the metadata of the entry.
154 * @param successCallback {Function} is called with a Metadata object
155 * @param errorCallback {Function} is called with a FileError
156 * @param metadataObject {Metadata} keys and values to set
157 */
158 setMetadata(successCallback: MetadataCallback, errorCallback: ErrorCallback, metadataObject: Metadata): void;
159 /**
160 * Move an entry to a different location on the file system. It is an error to try to:
161 *
162 * <ui>
163 * <li>move a directory inside itself or to any child at any depth;</li>
164 * <li>move an entry into its parent if a name different from its current one isn't provided;</li>
165 * <li>move a file to a path occupied by a directory;</li>
166 * <li>move a directory to a path occupied by a file;</li>
167 * <li>move any element to a path occupied by a directory which is not empty.</li>
168 * <ul>
169 *
170 * A move of a file on top of an existing file must attempt to delete and replace that file.
171 * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
172 */
173 moveTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
174 /**
175 * Copy an entry to a different location on the file system. It is an error to try to:
176 *
177 * <ul>
178 * <li> copy a directory inside itself or to any child at any depth;</li>
179 * <li> copy an entry into its parent if a name different from its current one isn't provided;</li>
180 * <li> copy a file to a path occupied by a directory;</li>
181 * <li> copy a directory to a path occupied by a file;</li>
182 * <li> copy any element to a path occupied by a directory which is not empty.</li>
183 * <li> A copy of a file on top of an existing file must attempt to delete and replace that file.</li>
184 * <li> A copy of a directory on top of an existing empty directory must attempt to delete and replace that
185 * directory.</li>
186 * </ul>
187 *
188 * Directory copies are always recursive--that is, they copy all contents of the directory.
189 */
190 copyTo(parent: DirectoryEntry, newName?: string, successCallback?: EntryCallback, errorCallback?: ErrorCallback): void;
191 /**
192 * Returns a URL that can be used to identify this entry. Unlike the URN defined in [FILE-API-ED], it has no specific
193 * expiration; as it describes a location on disk, it should be valid at least as long as that location exists.
194 */
195 toURL(): string;
196 /**
197 * Return a URL that can be passed across the bridge to identify this entry.
198 * @return string URL that can be passed across the bridge to identify this entry
199 */
200 toInternalURL(): string;
201 /**
202 * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to
203 * attempt to delete the root directory of a filesystem.
204 * @param successCallback A callback that is called on success.
205 * @param errorCallback A callback that is called when errors happen.
206 */
207 remove(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
208 /**
209 * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent
210 * is itself.
211 * @param successCallback A callback that is called to return the parent Entry.
212 * @param errorCallback A callback that is called when errors happen.
213 */
214 getParent(successCallback: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
215}
216/**
217 * This export interface represents a directory on a file system.
218 */
219export interface DirectoryEntry extends Entry {
220 /**
221 * Creates a new DirectoryReader to read Entries from this Directory.
222 */
223 createReader(): DirectoryReader;
224 /**
225 * Creates or looks up a file.
226 * @param path Either an absolute path or a relative path from this DirectoryEntry to the file to be looked up or
227 * created. It is an error to attempt to create a file whose immediate parent does not yet exist.
228 * @param options
229 * <ul>
230 * <li>If create and exclusive are both true, and the path already exists, getFile must fail.</li>
231 * <li>If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a
232 * zero-length file and return a corresponding FileEntry.</li>
233 * <li>If create is not true and the path doesn't exist, getFile must fail.</li>
234 * <li>If create is not true and the path exists, but is a directory, getFile must fail.</li>
235 * <li>Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.</li>
236 * </ul>
237 * @param successCallback A callback that is called to return the File selected or created.
238 * @param errorCallback A callback that is called when errors happen.
239 */
240 getFile(path: string, options?: Flags, successCallback?: FileEntryCallback, errorCallback?: ErrorCallback): void;
241 /**
242 * Creates or looks up a directory.
243 * @param path Either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up
244 * or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
245 * @param options
246 * <ul>
247 * <li>If create and exclusive are both true and the path already exists, getDirectory must fail.</li>
248 * <li>If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return
249 * a corresponding DirectoryEntry.</li>
250 * <li>If create is not true and the path doesn't exist, getDirectory must fail.</li>
251 * <li>If create is not true and the path exists, but is a file, getDirectory must fail.</li>
252 * <li>Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.</li>
253 * </ul>
254 * @param successCallback A callback that is called to return the DirectoryEntry selected or created.
255 * @param errorCallback A callback that is called when errors happen.
256 *
257 */
258 getDirectory(path: string, options?: Flags, successCallback?: DirectoryEntryCallback, errorCallback?: ErrorCallback): void;
259 /**
260 * Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory
261 * that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error
262 * to attempt to delete the root directory of a filesystem.
263 * @param successCallback A callback that is called on success.
264 * @param errorCallback A callback that is called when errors happen.
265 */
266 removeRecursively(successCallback: VoidCallback, errorCallback?: ErrorCallback): void;
267}
268/**
269 * This export interface lets a user list files and directories in a directory. If there are no additions to or
270 * deletions from a directory between the first and last call to readEntries, and no errors occur, then:
271 * <ul>
272 * <li> A series of calls to readEntries must return each entry in the directory exactly once.</li>
273 * <li> Once all entries have been returned, the next call to readEntries must produce an empty array.</li>
274 * <li> If not all entries have been returned, the array produced by readEntries must not be empty.</li>
275 * <li> The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].</li>
276 * </ul>
277 */
278export interface DirectoryReader {
279 localURL: string;
280 hasReadEntries: boolean;
281 /**
282 * Read the next block of entries from this directory.
283 * @param successCallback Called once per successful call to readEntries to deliver the next previously-unreported
284 * set of Entries in the associated Directory. If all Entries have already been returned from previous invocations
285 * of readEntries, successCallback must be called with a zero-length array as an argument.
286 * @param errorCallback A callback indicating that there was an error reading from the Directory.
287 */
288 readEntries(successCallback: EntriesCallback, errorCallback?: ErrorCallback): void;
289}
290/**
291 * This export interface represents a file on a file system.
292 */
293export interface FileEntry extends Entry {
294 /**
295 * Creates a new FileWriter associated with the file that this FileEntry represents.
296 * @param successCallback A callback that is called with the new FileWriter.
297 * @param errorCallback A callback that is called when errors happen.
298 */
299 createWriter(successCallback: FileWriterCallback, errorCallback?: ErrorCallback): void;
300 /**
301 * Returns a File that represents the current state of the file that this FileEntry represents.
302 * @param successCallback A callback that is called with the File.
303 * @param errorCallback A callback that is called when errors happen.
304 */
305 file(successCallback: FileCallback, errorCallback?: ErrorCallback): void;
306}
307/**
308 * When requestFileSystem() succeeds, the following callback is made.
309 */
310export declare type FileSystemCallback = (filesystem: FileSystem) => void;
311/**
312 * This export interface is the callback used to look up Entry objects.
313 */
314export declare type EntryCallback = (entry: Entry) => void;
315/**
316 * This export interface is the callback used to look up FileEntry objects.
317 */
318export declare type FileEntryCallback = (entry: FileEntry) => void;
319/**
320 * This export interface is the callback used to look up DirectoryEntry objects.
321 */
322export declare type DirectoryEntryCallback = (entry: DirectoryEntry) => void;
323/**
324 * When readEntries() succeeds, the following callback is made.
325 */
326export declare type EntriesCallback = (entries: Entry[]) => void;
327/**
328 * This export interface is the callback used to look up file and directory metadata.
329 */
330export declare type MetadataCallback = (metadata: Metadata) => void;
331/**
332 * This export interface is the callback used to create a FileWriter.
333 */
334export declare type FileWriterCallback = (fileWriter: FileWriter) => void;
335/**
336 * This export interface is the callback used to obtain a File.
337 */
338export declare type FileCallback = (file: IFile) => void;
339/**
340 * This export interface is the generic callback used to indicate success of an asynchronous method.
341 */
342export declare type VoidCallback = () => void;
343/**
344 * When an error occurs, the following callback is made.
345 */
346export declare type ErrorCallback = (err: FileError) => void;
347export interface RemoveResult {
348 success: boolean;
349 fileRemoved: Entry;
350}
351/** @hidden */
352export declare class FileSaver extends EventTarget {
353 /**
354 * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to
355 * INIT. This constructor must be visible when the script's global object is either a Window object or an object
356 * implementing the WorkerUtils interface.
357 */
358 constructor(data: Blob);
359 /**
360 * When the abort method is called, user agents must run the steps below:
361 * <ol>
362 * <li> If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything
363 * else. </li>
364 * <li> Set readyState to DONE. </li>
365 * <li> If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those
366 * tasks. </li>
367 * <li> Terminate the write algorithm being processed. </li>
368 * <li> Set the error attribute to a DOMError object of type "AbortError". </li>
369 * <li> Fire a progress event called abort </li>
370 * <li> Fire a progress event called write end </li>
371 * <li> Terminate this algorithm. </li>
372 * </ol>
373 */
374 abort(): void;
375 /**
376 * The blob is being written.
377 * @readonly
378 */
379 INIT: number;
380 /**
381 * The object has been constructed, but there is no pending write.
382 * @readonly
383 */
384 WRITING: number;
385 /**
386 * The entire Blob has been written to the file, an error occurred during the write, or the write was aborted using
387 * abort(). The FileSaver is no longer writing the blob.
388 * @readonly
389 */
390 DONE: number;
391 /**
392 * The FileSaver object can be in one of 3 states. The readyState attribute, on getting, must return the current
393 * state, which must be one of the following values:
394 * <ul>
395 * <li>INIT</li>
396 * <li>WRITING</li>
397 * <li>DONE</li>
398 * <ul>
399 * @readonly
400 */
401 readyState: number;
402 /**
403 * The last error that occurred on the FileSaver.
404 * @readonly
405 */
406 error: Error;
407 /**
408 * Handler for write start events
409 */
410 onwritestart: (event: ProgressEvent) => void;
411 /**
412 * Handler for progress events.
413 */
414 onprogress: (event: ProgressEvent) => void;
415 /**
416 * Handler for write events.
417 */
418 onwrite: (event: ProgressEvent) => void;
419 /**
420 * Handler for abort events.
421 */
422 onabort: (event: ProgressEvent) => void;
423 /**
424 * Handler for error events.
425 */
426 onerror: (event: ProgressEvent) => void;
427 /**
428 * Handler for write end events.
429 */
430 onwriteend: (event: ProgressEvent) => void;
431 /**
432 * When the FileSaver constructor is called, the user agent must return a new FileSaver object with readyState set to
433 * INIT. This constructor must be visible when the script's global object is either a Window object or an object
434 * implementing the WorkerUtils interface.
435 */
436 constructor(data: Blob);
437 /**
438 * When the abort method is called, user agents must run the steps below:
439 * <ol>
440 * <li> If readyState == DONE or readyState == INIT, terminate this overall series of steps without doing anything
441 * else. </li>
442 * <li> Set readyState to DONE. </li>
443 * <li> If there are any tasks from the object's FileSaver task source in one of the task queues, then remove those
444 * tasks. </li>
445 * <li> Terminate the write algorithm being processed. </li>
446 * <li> Set the error attribute to a DOMError object of type "AbortError". </li>
447 * <li> Fire a progress event called abort </li>
448 * <li> Fire a progress event called writeend </li>
449 * <li> Terminate this algorithm. </li>
450 * </ol>
451 */
452 abort(): void;
453}
454/**
455 * @hidden
456 * This interface expands on the FileSaver interface to allow for multiple write actions, rather than just saving a
457 * single Blob.
458 */
459export declare class FileWriter extends FileSaver {
460 /**
461 * The byte offset at which the next write to the file will occur. This must be no greater than length.
462 * A newly-created FileWriter must have position set to 0.
463 */
464 position: number;
465 /**
466 * The length of the file. If the user does not have read access to the file, this must be the highest byte offset at
467 * which the user has written.
468 */
469 length: number;
470 /**
471 * Write the supplied data to the file at position.
472 * @param data The blob to write.
473 */
474 write(data: ArrayBuffer | Blob | string): void;
475 /**
476 * Seek sets the file position at which the next write will occur.
477 * @param offset If nonnegative, an absolute byte offset into the file. If negative, an offset back from the end of
478 * the file.
479 */
480 seek(offset: number): void;
481 /**
482 * Changes the length of the file to that specified. If shortening the file, data beyond the new length must be
483 * discarded. If extending the file, the existing data must be zero-padded up to the new length.
484 * @param size The size to which the length of the file is to be adjusted, measured in bytes.
485 */
486 truncate(size: number): void;
487}
488export interface IWriteOptions {
489 replace?: boolean;
490 append?: boolean;
491 truncate?: number;
492}
493/** @hidden */
494export declare class FileError {
495 static NOT_FOUND_ERR: number;
496 static SECURITY_ERR: number;
497 static ABORT_ERR: number;
498 static NOT_READABLE_ERR: number;
499 static ENCODING_ERR: number;
500 static NO_MODIFICATION_ALLOWED_ERR: number;
501 static INVALID_STATE_ERR: number;
502 static SYNTAX_ERR: number;
503 static INVALID_MODIFICATION_ERR: number;
504 static QUOTA_EXCEEDED_ERR: number;
505 static TYPE_MISMATCH_ERR: number;
506 static PATH_EXISTS_ERR: number;
507 /** Error code */
508 code: number;
509 message: string;
510 constructor(code: number);
511}
512/** @hidden */
513export declare class FileReader {
514 static EMPTY: number;
515 static LOADING: number;
516 static DONE: number;
517 static READ_CHUNK_SIZE: number;
518 readyState: number;
519 error: Error;
520 result: string | ArrayBuffer;
521 onloadstart: (evt: ProgressEvent) => void;
522 onprogress: (evt: ProgressEvent) => void;
523 onload: (evt: ProgressEvent) => void;
524 onerror: (evt: ProgressEvent) => void;
525 onloadend: (evt: ProgressEvent) => void;
526 onabort: (evt: ProgressEvent) => void;
527 abort(): void;
528 readAsText(fe: IFile, encoding?: string): void;
529 readAsDataURL(fe: IFile): void;
530 readAsBinaryString(fe: IFile): void;
531 readAsArrayBuffer(fe: IFile): void;
532 /**
533 * @hidden
534 */
535 [key: string]: any;
536}
537/**
538 * @name File
539 * @premier filesystem
540 * @description
541 * This plugin implements a File API allowing read/write access to files residing on the device.
542 *
543 * The File class implements static convenience functions to access files and directories.
544 *
545 * Example:
546 * ```
547 * import { File } from '@ionic-native/file/ngx';
548 *
549 * constructor(private file: File) { }
550 *
551 * ...
552 *
553 * this.file.checkDir(this.file.dataDirectory, 'mydir').then(_ => console.log('Directory exists')).catch(err =>
554 * console.log('Directory doesn't exist'));
555 *
556 * ```
557 *
558 * This plugin is based on several specs, including : The HTML5 File API http: //www.w3.org/TR/FileAPI/
559 * The (now-defunct) Directories and System extensions Latest: http: //www.w3.org/TR/2012/WD-file-system-api-20120417/
560 * Although most of the plugin code was written when an earlier spec was current: http:
561 * //www.w3.org/TR/2011/WD-file-system-api-20110419/ It also implements the FileWriter spec : http:
562 * //dev.w3.org/2009/dap/file-system/file-writer.html
563 * @interfaces
564 * IFile
565 * Entry
566 * DirectoryEntry
567 * DirectoryReader
568 * FileSystem
569 */
570export declare class FileOriginal extends IonicNativePlugin {
571 /**
572 * Read-only directory where the application is installed.
573 */
574 applicationDirectory: string;
575 /**
576 * Read-only directory where the application is installed.
577 */
578 applicationStorageDirectory: string;
579 /**
580 * Where to put app-specific data files.
581 */
582 dataDirectory: string;
583 /**
584 * Cached files that should survive app restarts.
585 * Apps should not rely on the OS to delete files in here.
586 */
587 cacheDirectory: string;
588 /**
589 * Android: the application space on external storage.
590 */
591 externalApplicationStorageDirectory: string;
592 /**
593 * Android: Where to put app-specific data files on external storage.
594 */
595 externalDataDirectory: string;
596 /**
597 * Android: the application cache on external storage.
598 */
599 externalCacheDirectory: string;
600 /**
601 * Android: the external storage (SD card) root.
602 */
603 externalRootDirectory: string;
604 /**
605 * iOS: Temp directory that the OS can clear at will.
606 */
607 tempDirectory: string;
608 /**
609 * iOS: Holds app-specific files that should be synced (e.g. to iCloud).
610 */
611 syncedDataDirectory: string;
612 /**
613 * iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
614 */
615 documentsDirectory: string;
616 /**
617 * BlackBerry10: Files globally available to all apps
618 */
619 sharedDirectory: string;
620 cordovaFileError: any;
621 /**
622 * Get free disk space in Bytes
623 * @returns {Promise<number>} Returns a promise that resolves with the remaining free disk space in Bytes
624 */
625 getFreeDiskSpace(): Promise<number>;
626 /**
627 * Check if a directory exists in a certain path, directory.
628 *
629 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
630 * @param {string} dir Name of directory to check
631 * @returns {Promise<boolean>} Returns a Promise that resolves to true if the directory exists or rejects with an
632 * error.
633 */
634 checkDir(path: string, dir: string): Promise<boolean>;
635 /**
636 * Creates a new directory in the specific path.
637 * The replace boolean value determines whether to replace an existing directory with the same name.
638 * If an existing directory exists and the replace value is false, the promise will fail and return an error.
639 *
640 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
641 * @param {string} dirName Name of directory to create
642 * @param {boolean} replace If true, replaces file with same name. If false returns error
643 * @returns {Promise<DirectoryEntry>} Returns a Promise that resolves with a DirectoryEntry or rejects with an error.
644 */
645 createDir(path: string, dirName: string, replace: boolean): Promise<DirectoryEntry>;
646 /**
647 * Remove a directory at a given path.
648 *
649 * @param {string} path The path to the directory
650 * @param {string} dirName The directory name
651 * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
652 */
653 removeDir(path: string, dirName: string): Promise<RemoveResult>;
654 /**
655 * Move a directory to a given path.
656 *
657 * @param {string} path The source path to the directory
658 * @param {string} dirName The source directory name
659 * @param {string} newPath The destination path to the directory
660 * @param {string} newDirName The destination directory name
661 * @returns {Promise<DirectoryEntry|Entry>} Returns a Promise that resolves to the new DirectoryEntry object or
662 * rejects with an error.
663 */
664 moveDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<DirectoryEntry | Entry>;
665 /**
666 * Copy a directory in various methods. If destination directory exists, will fail to copy.
667 *
668 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
669 * @param {string} dirName Name of directory to copy
670 * @param {string} newPath Base FileSystem of new location
671 * @param {string} newDirName New name of directory to copy to (leave blank to remain the same)
672 * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry object or rejects with an error.
673 */
674 copyDir(path: string, dirName: string, newPath: string, newDirName: string): Promise<Entry>;
675 /**
676 * List files and directory from a given path.
677 *
678 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystems above
679 * @param {string} dirName Name of directory
680 * @returns {Promise<Entry[]>} Returns a Promise that resolves to an array of Entry objects or rejects with an error.
681 */
682 listDir(path: string, dirName: string): Promise<Entry[]>;
683 /**
684 * Removes all files and the directory from a desired location.
685 *
686 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
687 * @param {string} dirName Name of directory
688 * @returns {Promise<RemoveResult>} Returns a Promise that resolves with a RemoveResult or rejects with an error.
689 */
690 removeRecursively(path: string, dirName: string): Promise<RemoveResult>;
691 /**
692 * Check if a file exists in a certain path, directory.
693 *
694 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
695 * @param {string} file Name of file to check
696 * @returns {Promise<boolean>} Returns a Promise that resolves with a boolean or rejects with an error.
697 */
698 checkFile(path: string, file: string): Promise<boolean>;
699 /**
700 * Creates a new file in the specific path.
701 * The replace boolean value determines whether to replace an existing file with the same name.
702 * If an existing file exists and the replace value is false, the promise will fail and return an error.
703 *
704 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
705 * @param {string} fileName Name of file to create
706 * @param {boolean} replace If true, replaces file with same name. If false returns error
707 * @returns {Promise<FileEntry>} Returns a Promise that resolves to a FileEntry or rejects with an error.
708 */
709 createFile(path: string, fileName: string, replace: boolean): Promise<FileEntry>;
710 /**
711 * Removes a file from a desired location.
712 *
713 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
714 * @param {string} fileName Name of file to remove
715 * @returns {Promise<RemoveResult>} Returns a Promise that resolves to a RemoveResult or rejects with an error.
716 */
717 removeFile(path: string, fileName: string): Promise<RemoveResult>;
718 /**
719 * Write a new file to the desired location.
720 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
721 * @param {string} fileName path relative to base path
722 * @param {string | Blob | ArrayBuffer} text content, blob or ArrayBuffer to write
723 * @param {IWriteOptions} whether to replace/append to an existing file. See IWriteOptions for more information.
724 * @returns {Promise<any>} Returns a Promise that resolves to updated file entry or rejects with an error.
725 */
726 writeFile(path: string, fileName: string, text: string | Blob | ArrayBuffer, options?: IWriteOptions): Promise<any>;
727 /**
728 * Write content to FileEntry.
729 * @hidden
730 * Write to an existing file.
731 * @param {FileEntry} fe file entry object
732 * @param {string | Blob | ArrayBuffer} text text content or blob to write
733 * @param {IWriteOptions} options replace file if set to true. See WriteOptions for more information.
734 * @returns {Promise<FileEntry>} Returns a Promise that resolves to updated file entry or rejects with an error.
735 */
736 private writeFileEntry;
737 /**
738 * Write to an existing file.
739 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
740 * @param {string} fileName path relative to base path
741 * @param {string | Blob} text content or blob to write
742 * @returns {Promise<void>} Returns a Promise that resolves or rejects with an error.
743 */
744 writeExistingFile(path: string, fileName: string, text: string | Blob): Promise<void>;
745 /**
746 * Read the contents of a file as text.
747 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
748 * @param {string} file Name of file, relative to path.
749 * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string or rejects with
750 * an error.
751 */
752 readAsText(path: string, file: string): Promise<string>;
753 /**
754 * Read file and return data as a base64 encoded data url.
755 * A data url is of the form:
756 * data: [<mediatype>][;base64],<data>
757 *
758 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
759 * @param {string} file Name of file, relative to path.
760 * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as data URL or rejects
761 * with an error.
762 */
763 readAsDataURL(path: string, file: string): Promise<string>;
764 /**
765 * Read file and return data as a binary data.
766 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
767 * @param {string} file Name of file, relative to path.
768 * @returns {Promise<string>} Returns a Promise that resolves with the contents of the file as string rejects with an
769 * error.
770 */
771 readAsBinaryString(path: string, file: string): Promise<string>;
772 /**
773 * Read file and return data as an ArrayBuffer.
774 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
775 * @param {string} file Name of file, relative to path.
776 * @returns {Promise<ArrayBuffer>} Returns a Promise that resolves with the contents of the file as ArrayBuffer or
777 * rejects with an error.
778 */
779 readAsArrayBuffer(path: string, file: string): Promise<ArrayBuffer>;
780 /**
781 * Move a file to a given path.
782 *
783 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
784 * @param {string} fileName Name of file to move
785 * @param {string} newPath Base FileSystem of new location
786 * @param {string} newFileName New name of file to move to (leave blank to remain the same)
787 * @returns {Promise<Entry>} Returns a Promise that resolves to the new Entry or rejects with an error.
788 */
789 moveFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
790 /**
791 * Copy a file in various methods. If file exists, will fail to copy.
792 *
793 * @param {string} path Base FileSystem. Please refer to the iOS and Android filesystem above
794 * @param {string} fileName Name of file to copy
795 * @param {string} newPath Base FileSystem of new location
796 * @param {string} newFileName New name of file to copy to (leave blank to remain the same)
797 * @returns {Promise<Entry>} Returns a Promise that resolves to an Entry or rejects with an error.
798 */
799 copyFile(path: string, fileName: string, newPath: string, newFileName: string): Promise<Entry>;
800 /**
801 * @hidden
802 */
803 private fillErrorMessage;
804 /**
805 * Resolves a local file system URL
806 * @param fileUrl {string} file system url
807 * @returns {Promise<Entry>}
808 */
809 resolveLocalFilesystemUrl(fileUrl: string): Promise<Entry>;
810 /**
811 * Resolves a local directory url
812 * @param directoryUrl {string} directory system url
813 * @returns {Promise<DirectoryEntry>}
814 */
815 resolveDirectoryUrl(directoryUrl: string): Promise<DirectoryEntry>;
816 /**
817 * Get a directory
818 * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
819 * @param directoryName {string} Directory name
820 * @param flags {Flags} Options
821 * @returns {Promise<DirectoryEntry>}
822 */
823 getDirectory(directoryEntry: DirectoryEntry, directoryName: string, flags: Flags): Promise<DirectoryEntry>;
824 /**
825 * Get a file
826 * @param directoryEntry {DirectoryEntry} Directory entry, obtained by resolveDirectoryUrl method
827 * @param fileName {string} File name
828 * @param flags {Flags} Options
829 * @returns {Promise<FileEntry>}
830 */
831 getFile(directoryEntry: DirectoryEntry, fileName: string, flags: Flags): Promise<FileEntry>;
832 private readFile;
833 /**
834 * @hidden
835 */
836 private remove;
837 /**
838 * @hidden
839 */
840 private move;
841 /**
842 * @hidden
843 */
844 private copy;
845 /**
846 * @hidden
847 */
848 private readEntries;
849 /**
850 * @hidden
851 */
852 private rimraf;
853 /**
854 * @hidden
855 */
856 private createWriter;
857 /**
858 * @hidden
859 */
860 private write;
861 /**
862 * @hidden
863 */
864 private writeFileInChunks;
865}
866
867export declare const File: FileOriginal;
\No newline at end of file