How to use the react-native-fs.readdir function in react-native-fs

To help you get started, we’ve selected a few react-native-fs 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 rawtxapp / rawtxapp / src / NativeRtxModule.js View on Github external
const deleteOldNeutrino = async function(walletDir: string) {
  const d = walletDir + "/data/chain/bitcoin/testnet/";
  let contents = await RNFS.readdir(d);
  contents = contents.filter(c => c != "wallet.db");
  for (let c of contents) {
    try {
      await RNFS.unlink(d + c);
    } catch (err) {
      console.error("couldn't delete old neutrino", err);
    }
  }
};
github cliqz-oss / browser-core / platforms / react-native / persistent-map.es View on Github external
async keys() {
    return (await RNFS.readdir(this._mapDir)).map(fileName => fileName.split('.', 2)[0]);
  }
github cliqz-oss / browser-core / platforms / react-native / persistent-map.es View on Github external
async size() {
    return (await RNFS.readdir(this._mapDir)).length;
  }
github cliqz-oss / browser-core / platforms / react-native / persistent-map.es View on Github external
async _getFileForKey(key) {
    const dir = await RNFS.readdir(this._mapDir);
    return dir.find(v => v.startsWith(`${key}.`));
  }
github crownstone / CrownstoneApp / js / logging / LogUtil.ts View on Github external
function _cleanLogs(logPath, amountOfDaysStored = 3) {
  let allowedLogFiles = {};
  for (let i = 0; i < amountOfDaysStored; i++) {
    let timestamp = new Date().valueOf() - i*86400000;
    allowedLogFiles[getFilename(timestamp)] = true;
  }

  let flagForRemoval = [];
  RNFS.readdir(logPath)
    .then((files) => {
      for (let i = 0; i < files.length; i++) {
        if (files[i].substr(0,14) === "ConsumerAppLog" && allowedLogFiles[files[i]] !== true) {
          flagForRemoval.push(files[i]);
        }
      }
      for (let i = 0; i < flagForRemoval.length; i++) {
        FileUtil.safeDeleteFile(logPath + "/" + flagForRemoval[i]).catch(()=>{});
      }
    })
    .catch((err) => {
    });
}