1import { EventEmitter, UnavailabilityError } from 'expo-modules-core';
2import { Platform } from 'react-native';
3import { v4 as uuidv4 } from 'uuid';
4import ExponentFileSystem from './ExponentFileSystem';
5import { FileSystemSessionType, FileSystemUploadType, } from './FileSystem.types';
6if (!ExponentFileSystem) {
7    console.warn("No native ExponentFileSystem module found, are you sure the expo-file-system's module is linked properly?");
8}
9// Prevent webpack from pruning this.
10const _unused = new EventEmitter(ExponentFileSystem); // eslint-disable-line
11function normalizeEndingSlash(p) {
12    if (p != null) {
13        return p.replace(/\/*$/, '') + '/';
14    }
15    return null;
16}
17/**
18 * `file://` URI pointing to the directory where user documents for this app will be stored.
19 * Files stored here will remain until explicitly deleted by the app. Ends with a trailing `/`.
20 * Example uses are for files the user saves that they expect to see again.
21 */
22export const documentDirectory = normalizeEndingSlash(ExponentFileSystem.documentDirectory);
23/**
24 * `file://` URI pointing to the directory where temporary files used by this app will be stored.
25 * Files stored here may be automatically deleted by the system when low on storage.
26 * Example uses are for downloaded or generated files that the app just needs for one-time usage.
27 */
28export const cacheDirectory = normalizeEndingSlash(ExponentFileSystem.cacheDirectory);
29// @docsMissing
30export const { bundledAssets, bundleDirectory } = ExponentFileSystem;
31/**
32 * Get metadata information about a file, directory or external content/asset.
33 * @param fileUri URI to the file or directory. See [supported URI schemes](#supported-uri-schemes).
34 * @param options A map of options represented by [`GetInfoAsyncOptions`](#getinfoasyncoptions) type.
35 * @return A Promise that resolves to a `FileInfo` object. If no item exists at this URI,
36 * the returned Promise resolves to `FileInfo` object in form of `{ exists: false, isDirectory: false }`.
37 */
38export async function getInfoAsync(fileUri, options = {}) {
39    if (!ExponentFileSystem.getInfoAsync) {
40        throw new UnavailabilityError('expo-file-system', 'getInfoAsync');
41    }
42    return await ExponentFileSystem.getInfoAsync(fileUri, options);
43}
44/**
45 * Read the entire contents of a file as a string. Binary will be returned in raw format, you will need to append `data:image/png;base64,` to use it as Base64.
46 * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.
47 * @param options A map of read options represented by [`ReadingOptions`](#readingoptions) type.
48 * @return A Promise that resolves to a string containing the entire contents of the file.
49 */
50export async function readAsStringAsync(fileUri, options = {}) {
51    if (!ExponentFileSystem.readAsStringAsync) {
52        throw new UnavailabilityError('expo-file-system', 'readAsStringAsync');
53    }
54    return await ExponentFileSystem.readAsStringAsync(fileUri, options);
55}
56/**
57 * Takes a `file://` URI and converts it into content URI (`content://`) so that it can be accessed by other applications outside of Expo.
58 * @param fileUri The local URI of the file. If there is no file at this URI, an exception will be thrown.
59 * @example
60 * ```js
61 * FileSystem.getContentUriAsync(uri).then(cUri => {
62 *   console.log(cUri);
63 *   IntentLauncher.startActivityAsync('android.intent.action.VIEW', {
64 *     data: cUri,
65 *     flags: 1,
66 *   });
67 * });
68 * ```
69 * @return Returns a Promise that resolves to a `string` containing a `content://` URI pointing to the file.
70 * The URI is the same as the `fileUri` input parameter but in a different format.
71 * @platform android
72 */
73export async function getContentUriAsync(fileUri) {
74    if (Platform.OS === 'android') {
75        if (!ExponentFileSystem.getContentUriAsync) {
76            throw new UnavailabilityError('expo-file-system', 'getContentUriAsync');
77        }
78        return await ExponentFileSystem.getContentUriAsync(fileUri);
79    }
80    else {
81        return fileUri;
82    }
83}
84/**
85 * Write the entire contents of a file as a string.
86 * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.
87 * > Note: when you're using SAF URI the file needs to exist. You can't create a new file.
88 * @param contents The string to replace the contents of the file with.
89 * @param options A map of write options represented by [`WritingOptions`](#writingoptions) type.
90 */
91export async function writeAsStringAsync(fileUri, contents, options = {}) {
92    if (!ExponentFileSystem.writeAsStringAsync) {
93        throw new UnavailabilityError('expo-file-system', 'writeAsStringAsync');
94    }
95    return await ExponentFileSystem.writeAsStringAsync(fileUri, contents, options);
96}
97/**
98 * Delete a file or directory. If the URI points to a directory, the directory and all its contents are recursively deleted.
99 * @param fileUri `file://` or [SAF](#saf-uri) URI to the file or directory.
100 * @param options A map of write options represented by [`DeletingOptions`](#deletingoptions) type.
101 */
102export async function deleteAsync(fileUri, options = {}) {
103    if (!ExponentFileSystem.deleteAsync) {
104        throw new UnavailabilityError('expo-file-system', 'deleteAsync');
105    }
106    return await ExponentFileSystem.deleteAsync(fileUri, options);
107}
108export async function deleteLegacyDocumentDirectoryAndroid() {
109    if (Platform.OS !== 'android' || documentDirectory == null) {
110        return;
111    }
112    const legacyDocumentDirectory = `${documentDirectory}ExperienceData/`;
113    return await deleteAsync(legacyDocumentDirectory, { idempotent: true });
114}
115/**
116 * Move a file or directory to a new location.
117 * @param options A map of move options represented by [`RelocatingOptions`](#relocatingoptions) type.
118 */
119export async function moveAsync(options) {
120    if (!ExponentFileSystem.moveAsync) {
121        throw new UnavailabilityError('expo-file-system', 'moveAsync');
122    }
123    return await ExponentFileSystem.moveAsync(options);
124}
125/**
126 * Create a copy of a file or directory. Directories are recursively copied with all of their contents.
127 * It can be also used to copy content shared by other apps to local filesystem.
128 * @param options A map of move options represented by [`RelocatingOptions`](#relocatingoptions) type.
129 */
130export async function copyAsync(options) {
131    if (!ExponentFileSystem.copyAsync) {
132        throw new UnavailabilityError('expo-file-system', 'copyAsync');
133    }
134    return await ExponentFileSystem.copyAsync(options);
135}
136/**
137 * Create a new empty directory.
138 * @param fileUri `file://` URI to the new directory to create.
139 * @param options A map of create directory options represented by [`MakeDirectoryOptions`](#makedirectoryoptions) type.
140 */
141export async function makeDirectoryAsync(fileUri, options = {}) {
142    if (!ExponentFileSystem.makeDirectoryAsync) {
143        throw new UnavailabilityError('expo-file-system', 'makeDirectoryAsync');
144    }
145    return await ExponentFileSystem.makeDirectoryAsync(fileUri, options);
146}
147/**
148 * Enumerate the contents of a directory.
149 * @param fileUri `file://` URI to the directory.
150 * @return A Promise that resolves to an array of strings, each containing the name of a file or directory contained in the directory at `fileUri`.
151 */
152export async function readDirectoryAsync(fileUri) {
153    if (!ExponentFileSystem.readDirectoryAsync) {
154        throw new UnavailabilityError('expo-file-system', 'readDirectoryAsync');
155    }
156    return await ExponentFileSystem.readDirectoryAsync(fileUri, {});
157}
158/**
159 * Gets the available internal disk storage size, in bytes. This returns the free space on the data partition that hosts all of the internal storage for all apps on the device.
160 * @return Returns a Promise that resolves to the number of bytes available on the internal disk, or JavaScript's [`MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
161 * if the capacity is greater than 2<sup>53</sup> - 1 bytes.
162 */
163export async function getFreeDiskStorageAsync() {
164    if (!ExponentFileSystem.getFreeDiskStorageAsync) {
165        throw new UnavailabilityError('expo-file-system', 'getFreeDiskStorageAsync');
166    }
167    return await ExponentFileSystem.getFreeDiskStorageAsync();
168}
169/**
170 * Gets total internal disk storage size, in bytes. This is the total capacity of the data partition that hosts all the internal storage for all apps on the device.
171 * @return Returns a Promise that resolves to a number that specifies the total internal disk storage capacity in bytes, or JavaScript's [`MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)
172 * if the capacity is greater than 2<sup>53</sup> - 1 bytes.
173 */
174export async function getTotalDiskCapacityAsync() {
175    if (!ExponentFileSystem.getTotalDiskCapacityAsync) {
176        throw new UnavailabilityError('expo-file-system', 'getTotalDiskCapacityAsync');
177    }
178    return await ExponentFileSystem.getTotalDiskCapacityAsync();
179}
180/**
181 * Download the contents at a remote URI to a file in the app's file system. The directory for a local file uri must exist prior to calling this function.
182 * @param uri The remote URI to download from.
183 * @param fileUri The local URI of the file to download to. If there is no file at this URI, a new one is created.
184 * If there is a file at this URI, its contents are replaced. The directory for the file must exist.
185 * @param options A map of download options represented by [`DownloadOptions`](#downloadoptions) type.
186 * @example
187 * ```js
188 * FileSystem.downloadAsync(
189 *   'http://techslides.com/demos/sample-videos/small.mp4',
190 *   FileSystem.documentDirectory + 'small.mp4'
191 * )
192 *   .then(({ uri }) => {
193 *     console.log('Finished downloading to ', uri);
194 *   })
195 *   .catch(error => {
196 *     console.error(error);
197 *   });
198 * ```
199 * @return Returns a Promise that resolves to a `FileSystemDownloadResult` object.
200 */
201export async function downloadAsync(uri, fileUri, options = {}) {
202    if (!ExponentFileSystem.downloadAsync) {
203        throw new UnavailabilityError('expo-file-system', 'downloadAsync');
204    }
205    return await ExponentFileSystem.downloadAsync(uri, fileUri, {
206        sessionType: FileSystemSessionType.BACKGROUND,
207        ...options,
208    });
209}
210/**
211 * Upload the contents of the file pointed by `fileUri` to the remote url.
212 * @param url The remote URL, where the file will be sent.
213 * @param fileUri The local URI of the file to send. The file must exist.
214 * @param options A map of download options represented by [`FileSystemUploadOptions`](#filesystemuploadoptions) type.
215 * @example
216 * **Client**
217 *
218 * ```js
219 * import * as FileSystem from 'expo-file-system';
220 *
221 * try {
222 *   const response = await FileSystem.uploadAsync(`http://192.168.0.1:1234/binary-upload`, fileUri, {
223 *     fieldName: 'file',
224 *     httpMethod: 'PATCH',
225 *     uploadType: FileSystem.FileSystemUploadType.BINARY_CONTENT,
226 *   });
227 *   console.log(JSON.stringify(response, null, 4));
228 * } catch (error) {
229 *   console.log(error);
230 * }
231 * ```
232 *
233 * **Server**
234 *
235 * Please refer to the "[Server: Handling multipart requests](#server-handling-multipart-requests)" example - there is code for a simple Node.js server.
236 * @return Returns a Promise that resolves to `FileSystemUploadResult` object.
237 */
238export async function uploadAsync(url, fileUri, options = {}) {
239    if (!ExponentFileSystem.uploadAsync) {
240        throw new UnavailabilityError('expo-file-system', 'uploadAsync');
241    }
242    return await ExponentFileSystem.uploadAsync(url, fileUri, {
243        sessionType: FileSystemSessionType.BACKGROUND,
244        uploadType: FileSystemUploadType.BINARY_CONTENT,
245        ...options,
246        httpMethod: (options.httpMethod || 'POST').toUpperCase(),
247    });
248}
249/**
250 * Create a `DownloadResumable` object which can start, pause, and resume a download of contents at a remote URI to a file in the app's file system.
251 * > Note: You need to call `downloadAsync()`, on a `DownloadResumable` instance to initiate the download.
252 * The `DownloadResumable` object has a callback that provides download progress updates.
253 * Downloads can be resumed across app restarts by using `AsyncStorage` to store the `DownloadResumable.savable()` object for later retrieval.
254 * The `savable` object contains the arguments required to initialize a new `DownloadResumable` object to resume the download after an app restart.
255 * The directory for a local file uri must exist prior to calling this function.
256 * @param uri The remote URI to download from.
257 * @param fileUri The local URI of the file to download to. If there is no file at this URI, a new one is created.
258 * If there is a file at this URI, its contents are replaced. The directory for the file must exist.
259 * @param options A map of download options represented by [`DownloadOptions`](#downloadoptions) type.
260 * @param callback This function is called on each data write to update the download progress.
261 * > **Note**: When the app has been moved to the background, this callback won't be fired until it's moved to the foreground.
262 * @param resumeData The string which allows the api to resume a paused download. This is set on the `DownloadResumable` object automatically when a download is paused.
263 * When initializing a new `DownloadResumable` this should be `null`.
264 */
265export function createDownloadResumable(uri, fileUri, options, callback, resumeData) {
266    return new DownloadResumable(uri, fileUri, options, callback, resumeData);
267}
268export function createUploadTask(url, fileUri, options, callback) {
269    return new UploadTask(url, fileUri, options, callback);
270}
271function isUploadProgressData(data) {
272    return 'totalBytesSent' in data;
273}
274export class FileSystemCancellableNetworkTask {
275    _uuid = uuidv4();
276    taskWasCanceled = false;
277    emitter = new EventEmitter(ExponentFileSystem);
278    subscription;
279    // @docsMissing
280    async cancelAsync() {
281        if (!ExponentFileSystem.networkTaskCancelAsync) {
282            throw new UnavailabilityError('expo-file-system', 'networkTaskCancelAsync');
283        }
284        this.removeSubscription();
285        this.taskWasCanceled = true;
286        return await ExponentFileSystem.networkTaskCancelAsync(this.uuid);
287    }
288    isTaskCancelled() {
289        if (this.taskWasCanceled) {
290            console.warn('This task was already canceled.');
291            return true;
292        }
293        return false;
294    }
295    get uuid() {
296        return this._uuid;
297    }
298    addSubscription() {
299        if (this.subscription) {
300            return;
301        }
302        this.subscription = this.emitter.addListener(this.getEventName(), (event) => {
303            if (event.uuid === this.uuid) {
304                const callback = this.getCallback();
305                if (callback) {
306                    if (isUploadProgressData(event.data)) {
307                        const data = {
308                            ...event.data,
309                            get totalByteSent() {
310                                console.warn('Key "totalByteSent" in File System UploadProgressData is deprecated and will be removed in SDK 49, use "totalBytesSent" instead');
311                                return this.totalBytesSent;
312                            },
313                        };
314                        return callback(data);
315                    }
316                    callback(event.data);
317                }
318            }
319        });
320    }
321    removeSubscription() {
322        if (!this.subscription) {
323            return;
324        }
325        this.emitter.removeSubscription(this.subscription);
326        this.subscription = null;
327    }
328}
329export class UploadTask extends FileSystemCancellableNetworkTask {
330    url;
331    fileUri;
332    callback;
333    options;
334    constructor(url, fileUri, options, callback) {
335        super();
336        this.url = url;
337        this.fileUri = fileUri;
338        this.callback = callback;
339        const httpMethod = (options?.httpMethod?.toUpperCase() ||
340            'POST');
341        this.options = {
342            sessionType: FileSystemSessionType.BACKGROUND,
343            uploadType: FileSystemUploadType.BINARY_CONTENT,
344            ...options,
345            httpMethod,
346        };
347    }
348    getEventName() {
349        return 'expo-file-system.uploadProgress';
350    }
351    getCallback() {
352        return this.callback;
353    }
354    // @docsMissing
355    async uploadAsync() {
356        if (!ExponentFileSystem.uploadTaskStartAsync) {
357            throw new UnavailabilityError('expo-file-system', 'uploadTaskStartAsync');
358        }
359        if (this.isTaskCancelled()) {
360            return;
361        }
362        this.addSubscription();
363        const result = await ExponentFileSystem.uploadTaskStartAsync(this.url, this.fileUri, this.uuid, this.options);
364        this.removeSubscription();
365        return result;
366    }
367}
368export class DownloadResumable extends FileSystemCancellableNetworkTask {
369    url;
370    _fileUri;
371    options;
372    callback;
373    resumeData;
374    constructor(url, _fileUri, options = {}, callback, resumeData) {
375        super();
376        this.url = url;
377        this._fileUri = _fileUri;
378        this.options = options;
379        this.callback = callback;
380        this.resumeData = resumeData;
381    }
382    get fileUri() {
383        return this._fileUri;
384    }
385    getEventName() {
386        return 'expo-file-system.downloadProgress';
387    }
388    getCallback() {
389        return this.callback;
390    }
391    /**
392     * Download the contents at a remote URI to a file in the app's file system.
393     * @return Returns a Promise that resolves to `FileSystemDownloadResult` object, or to `undefined` when task was cancelled.
394     */
395    async downloadAsync() {
396        if (!ExponentFileSystem.downloadResumableStartAsync) {
397            throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');
398        }
399        if (this.isTaskCancelled()) {
400            return;
401        }
402        this.addSubscription();
403        return await ExponentFileSystem.downloadResumableStartAsync(this.url, this._fileUri, this.uuid, this.options, this.resumeData);
404    }
405    /**
406     * Pause the current download operation. `resumeData` is added to the `DownloadResumable` object after a successful pause operation.
407     * Returns an object that can be saved with `AsyncStorage` for future retrieval (the same object that is returned from calling `FileSystem.DownloadResumable.savable()`).
408     * @return Returns a Promise that resolves to `DownloadPauseState` object.
409     */
410    async pauseAsync() {
411        if (!ExponentFileSystem.downloadResumablePauseAsync) {
412            throw new UnavailabilityError('expo-file-system', 'downloadResumablePauseAsync');
413        }
414        if (this.isTaskCancelled()) {
415            return {
416                fileUri: this._fileUri,
417                options: this.options,
418                url: this.url,
419            };
420        }
421        const pauseResult = await ExponentFileSystem.downloadResumablePauseAsync(this.uuid);
422        this.removeSubscription();
423        if (pauseResult) {
424            this.resumeData = pauseResult.resumeData;
425            return this.savable();
426        }
427        else {
428            throw new Error('Unable to generate a savable pause state');
429        }
430    }
431    /**
432     * Resume a paused download operation.
433     * @return Returns a Promise that resolves to `FileSystemDownloadResult` object, or to `undefined` when task was cancelled.
434     */
435    async resumeAsync() {
436        if (!ExponentFileSystem.downloadResumableStartAsync) {
437            throw new UnavailabilityError('expo-file-system', 'downloadResumableStartAsync');
438        }
439        if (this.isTaskCancelled()) {
440            return;
441        }
442        this.addSubscription();
443        return await ExponentFileSystem.downloadResumableStartAsync(this.url, this.fileUri, this.uuid, this.options, this.resumeData);
444    }
445    /**
446     * Method to get the object which can be saved with `AsyncStorage` for future retrieval.
447     * @returns Returns object in shape of `DownloadPauseState` type.
448     */
449    savable() {
450        return {
451            url: this.url,
452            fileUri: this.fileUri,
453            options: this.options,
454            resumeData: this.resumeData,
455        };
456    }
457}
458const baseReadAsStringAsync = readAsStringAsync;
459const baseWriteAsStringAsync = writeAsStringAsync;
460const baseDeleteAsync = deleteAsync;
461const baseMoveAsync = moveAsync;
462const baseCopyAsync = copyAsync;
463/**
464 * The `StorageAccessFramework` is a namespace inside of the `expo-file-system` module, which encapsulates all functions which can be used with [SAF URIs](#saf-uri).
465 * You can read more about SAF in the [Android documentation](https://developer.android.com/guide/topics/providers/document-provider).
466 *
467 * @example
468 * # Basic Usage
469 *
470 * ```ts
471 * import { StorageAccessFramework } from 'expo-file-system';
472 *
473 * // Requests permissions for external directory
474 * const permissions = await StorageAccessFramework.requestDirectoryPermissionsAsync();
475 *
476 * if (permissions.granted) {
477 *   // Gets SAF URI from response
478 *   const uri = permissions.directoryUri;
479 *
480 *   // Gets all files inside of selected directory
481 *   const files = await StorageAccessFramework.readDirectoryAsync(uri);
482 *   alert(`Files inside ${uri}:\n\n${JSON.stringify(files)}`);
483 * }
484 * ```
485 *
486 * # Migrating an album
487 *
488 * ```ts
489 * import * as MediaLibrary from 'expo-media-library';
490 * import * as FileSystem from 'expo-file-system';
491 * const { StorageAccessFramework } = FileSystem;
492 *
493 * async function migrateAlbum(albumName: string) {
494 *   // Gets SAF URI to the album
495 *   const albumUri = StorageAccessFramework.getUriForDirectoryInRoot(albumName);
496 *
497 *   // Requests permissions
498 *   const permissions = await StorageAccessFramework.requestDirectoryPermissionsAsync(albumUri);
499 *   if (!permissions.granted) {
500 *     return;
501 *   }
502 *
503 *   const permittedUri = permissions.directoryUri;
504 *   // Checks if users selected the correct folder
505 *   if (!permittedUri.includes(albumName)) {
506 *     return;
507 *   }
508 *
509 *   const mediaLibraryPermissions = await MediaLibrary.requestPermissionsAsync();
510 *   if (!mediaLibraryPermissions.granted) {
511 *     return;
512 *   }
513 *
514 *   // Moves files from external storage to internal storage
515 *   await StorageAccessFramework.moveAsync({
516 *     from: permittedUri,
517 *     to: FileSystem.documentDirectory!,
518 *   });
519 *
520 *   const outputDir = FileSystem.documentDirectory! + albumName;
521 *   const migratedFiles = await FileSystem.readDirectoryAsync(outputDir);
522 *
523 *   // Creates assets from local files
524 *   const [newAlbumCreator, ...assets] = await Promise.all(
525 *     migratedFiles.map<Promise<MediaLibrary.Asset>>(
526 *       async fileName => await MediaLibrary.createAssetAsync(outputDir + '/' + fileName)
527 *     )
528 *   );
529 *
530 *   // Album was empty
531 *   if (!newAlbumCreator) {
532 *     return;
533 *   }
534 *
535 *   // Creates a new album in the scoped directory
536 *   const newAlbum = await MediaLibrary.createAlbumAsync(albumName, newAlbumCreator, false);
537 *   if (assets.length) {
538 *     await MediaLibrary.addAssetsToAlbumAsync(assets, newAlbum, false);
539 *   }
540 * }
541 * ```
542 * @platform Android
543 */
544export var StorageAccessFramework;
545(function (StorageAccessFramework) {
546    /**
547     * Gets a [SAF URI](#saf-uri) pointing to a folder in the Android root directory. You can use this function to get URI for
548     * `StorageAccessFramework.requestDirectoryPermissionsAsync()` when you trying to migrate an album. In that case, the name of the album is the folder name.
549     * @param folderName The name of the folder which is located in the Android root directory.
550     * @return Returns a [SAF URI](#saf-uri) to a folder.
551     */
552    function getUriForDirectoryInRoot(folderName) {
553        return `content://com.android.externalstorage.documents/tree/primary:${folderName}/document/primary:${folderName}`;
554    }
555    StorageAccessFramework.getUriForDirectoryInRoot = getUriForDirectoryInRoot;
556    /**
557     * Allows users to select a specific directory, granting your app access to all of the files and sub-directories within that directory.
558     * @param initialFileUrl The [SAF URI](#saf-uri) of the directory that the file picker should display when it first loads.
559     * If URI is incorrect or points to a non-existing folder, it's ignored.
560     * @platform android 11+
561     * @return Returns a Promise that resolves to `FileSystemRequestDirectoryPermissionsResult` object.
562     */
563    async function requestDirectoryPermissionsAsync(initialFileUrl = null) {
564        if (!ExponentFileSystem.requestDirectoryPermissionsAsync) {
565            throw new UnavailabilityError('expo-file-system', 'StorageAccessFramework.requestDirectoryPermissionsAsync');
566        }
567        return await ExponentFileSystem.requestDirectoryPermissionsAsync(initialFileUrl);
568    }
569    StorageAccessFramework.requestDirectoryPermissionsAsync = requestDirectoryPermissionsAsync;
570    /**
571     * Enumerate the contents of a directory.
572     * @param dirUri [SAF](#saf-uri) URI to the directory.
573     * @return A Promise that resolves to an array of strings, each containing the full [SAF URI](#saf-uri) of a file or directory contained in the directory at `fileUri`.
574     */
575    async function readDirectoryAsync(dirUri) {
576        if (!ExponentFileSystem.readSAFDirectoryAsync) {
577            throw new UnavailabilityError('expo-file-system', 'StorageAccessFramework.readDirectoryAsync');
578        }
579        return await ExponentFileSystem.readSAFDirectoryAsync(dirUri, {});
580    }
581    StorageAccessFramework.readDirectoryAsync = readDirectoryAsync;
582    /**
583     * Creates a new empty directory.
584     * @param parentUri The [SAF](#saf-uri) URI to the parent directory.
585     * @param dirName The name of new directory.
586     * @return A Promise that resolves to a [SAF URI](#saf-uri) to the created directory.
587     */
588    async function makeDirectoryAsync(parentUri, dirName) {
589        if (!ExponentFileSystem.makeSAFDirectoryAsync) {
590            throw new UnavailabilityError('expo-file-system', 'StorageAccessFramework.makeDirectoryAsync');
591        }
592        return await ExponentFileSystem.makeSAFDirectoryAsync(parentUri, dirName);
593    }
594    StorageAccessFramework.makeDirectoryAsync = makeDirectoryAsync;
595    /**
596     * Creates a new empty file.
597     * @param parentUri The [SAF](#saf-uri) URI to the parent directory.
598     * @param fileName The name of new file **without the extension**.
599     * @param mimeType The MIME type of new file.
600     * @return A Promise that resolves to a [SAF URI](#saf-uri) to the created file.
601     */
602    async function createFileAsync(parentUri, fileName, mimeType) {
603        if (!ExponentFileSystem.createSAFFileAsync) {
604            throw new UnavailabilityError('expo-file-system', 'StorageAccessFramework.createFileAsync');
605        }
606        return await ExponentFileSystem.createSAFFileAsync(parentUri, fileName, mimeType);
607    }
608    StorageAccessFramework.createFileAsync = createFileAsync;
609    /**
610     * Alias for [`writeAsStringAsync`](#filesystemwriteasstringasyncfileuri-contents-options) method.
611     */
612    StorageAccessFramework.writeAsStringAsync = baseWriteAsStringAsync;
613    /**
614     * Alias for [`readAsStringAsync`](#filesystemreadasstringasyncfileuri-options) method.
615     */
616    StorageAccessFramework.readAsStringAsync = baseReadAsStringAsync;
617    /**
618     * Alias for [`deleteAsync`](#filesystemdeleteasyncfileuri-options) method.
619     */
620    StorageAccessFramework.deleteAsync = baseDeleteAsync;
621    /**
622     * Alias for [`moveAsync`](#filesystemmoveasyncoptions) method.
623     */
624    StorageAccessFramework.moveAsync = baseMoveAsync;
625    /**
626     * Alias fro [`copyAsync`](#filesystemcopyasyncoptions) method.
627     */
628    StorageAccessFramework.copyAsync = baseCopyAsync;
629})(StorageAccessFramework || (StorageAccessFramework = {}));
630//# sourceMappingURL=FileSystem.js.map