How to use the expo-file-system.readDirectoryAsync function in expo-file-system

To help you get started, we’ve selected a few expo-file-system examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / expo-file-system_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-file-system.js View on Github external
it('should raises an error when pass invalid arguments', () => {
    // $ExpectError: first argument is required
    readDirectoryAsync();
    // $ExpectError: first argument must be a string
    readDirectoryAsync(69);
  });
});
github flow-typed / flow-typed / definitions / npm / expo-file-system_v4.x.x / flow_v0.69.0-v0.103.x / test_expo-file-system.js View on Github external
it('should passes when used properly', () => {
    readDirectoryAsync('fileUri').then(files => {
      (files: Array);

      // $ExpectError: check any
      (files: number);
    });
  });
github bugsnag / bugsnag-js / packages / delivery-expo / queue.js View on Github external
async _truncate () {
    // this isn't atomic so only enter this method once at any time
    if (this._truncating) return
    this._truncating = true

    try {
      // list the payloads in order
      const payloads = (await FileSystem.readDirectoryAsync(this._path))
        .filter(f => filenameRe.test(f)).sort()

      // figure out how many over MAX_ITEMS we are
      const diff = payloads.length - MAX_ITEMS

      // do nothing if within the limit
      if (diff < 0) {
        this._truncating = false
        return
      }

      // wait for each of the items over the limit to be removed
      await Promise.all(
        payloads.slice(0, diff)
          .map(f => this.remove(`${this._path}/${f}`))
      )
github bugsnag / bugsnag-js / packages / delivery-expo / queue.js View on Github external
async peek () {
    try {
      const payloads = await FileSystem.readDirectoryAsync(this._path)
      const payloadFileName = payloads.filter(f => filenameRe.test(f)).sort()[0]
      if (!payloadFileName) return null
      const id = `${this._path}/${payloadFileName}`

      try {
        const payloadJson = await FileSystem.readAsStringAsync(id)
        const payload = JSON.parse(payloadJson)
        return { id, payload }
      } catch (e) {
        // if we got here it's because
        // a) JSON.parse failed or
        // b) the file can no longer be read (maybe it was truncated?)
        // in both cases we want to speculatively remove it and try peeking again
        await this.remove(id)
        return this.peek()
      }
github expo / expo / packages / expo / build / DataMigrationHelper.js View on Github external
async function doesOldFilesDirectoryContainLock(path) {
    const children = await FileSystem.readDirectoryAsync(path);
    return children.indexOf(LOCK_FILE_NAME) > -1;
}
async function addLockToOldFilesDirectory(path) {
github expo / expo / packages / expo / build / DataMigrationHelper.js View on Github external
async function treeSearch(relativePath, legacyPath, newPath, resolveConflict) {
    const currentNewPath = `${newPath}${relativePath}`;
    const currentLegacyPath = `${legacyPath}${relativePath}`;
    const legacyPathInfo = await FileSystem.getInfoAsync(currentLegacyPath);
    const newPathInfo = await FileSystem.getInfoAsync(currentNewPath);
    if (legacyPathInfo.exists && !newPathInfo.exists) {
        await FileSystem.copyAsync({
            from: currentLegacyPath,
            to: currentNewPath,
        });
        await FileSystem.deleteAsync(currentLegacyPath);
        return;
    }
    if (legacyPathInfo.isDirectory) {
        const children = await FileSystem.readDirectoryAsync(currentLegacyPath);
        for (let child of children) {
            await treeSearch(relativePath + `${child}/`, legacyPath, newPath, resolveConflict);
        }
    }
    else {
        await resolveConflict(currentLegacyPath, currentNewPath);
    }
}
async function doesOldFilesDirectoryContainLock(path) {
github Nohac / redux-persist-expo-fs-storage / index.js View on Github external
withCallback(callback, async () => {
      await FileSystem.makeDirectoryAsync(baseFolder, {
        intermediates: true,
      });
      const baseFolderLength = baseFolder.length;
      const files = await FileSystem.readDirectoryAsync(baseFolder);
      return files.map(fileUri =>
        decodeURIComponent(fileUri.substring(baseFolderLength)),
      );
    });
github expo / expo / apps / native-component-list / src / screens / Camera / GalleryScreen.tsx View on Github external
componentDidMount = async () => {
    const photos = await FileSystem.readDirectoryAsync(PHOTOS_DIR);
    this.setState({ photos });
  }