How to use the graceful-fs.createReadStream function in graceful-fs

To help you get started, we’ve selected a few graceful-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 hw2-archive / upt / src / lib / util / extract.js View on Github external
function extractTarGz (archive, dst) {
    var deferred = Q.defer();

    fs.createReadStream(archive)
            .on('error', deferred.reject)
            .pipe(zlib.createGunzip())
            .on('error', deferred.reject)
            .pipe(tar.Extract({
                path: dst,
                follow: false, // Do not follow symlinks (#699)
                filter: filterSymlinks   // Filter symlink files
            }))
            .on('error', deferred.reject)
            .on('close', deferred.resolve.bind(deferred, dst));

    return deferred.promise;
}
github nullivex / nodist / bin / node_modules / npm / lib / utils / tar.js View on Github external
function gunzTarPerm (tarball, target, dMode, fMode, uid, gid, cb_) {
  if (!dMode) dMode = npm.modes.exec
  if (!fMode) fMode = npm.modes.file
  log.silly("gunzTarPerm", "modes", [dMode.toString(8), fMode.toString(8)])

  var cbCalled = false
  function cb (er) {
    if (cbCalled) return
    cbCalled = true
    cb_(er, target)
  }

  var fst = fs.createReadStream(tarball)

  // figure out who we're supposed to be, if we're not pretending
  // to be a specific user.
  if (npm.config.get("unsafe-perm") && process.platform !== "win32") {
    uid = myUid
    gid = myGid
  }

  function extractEntry (entry) {
    log.silly("gunzTarPerm", "extractEntry", entry.path)
    // never create things that are user-unreadable,
    // or dirs that are user-un-listable. Only leads to headaches.
    var originalMode = entry.mode = entry.mode || entry.props.mode
    entry.mode = entry.mode | (entry.type === "Directory" ? dMode : fMode)
    entry.mode = entry.mode & (~npm.modes.umask)
    entry.props.mode = entry.mode
github othiym23 / packard / test / metadata-read-flac.js View on Github external
stat(paths[0], function (er, stats) {
      if (er) throw er
      createReadStream(paths[0]).pipe(reader(
        { path: paths[0], stats: stats },
        new Map(),
        function (info) {
          var track = info.track
          t.ok(track, 'should get back a track')
          t.equal(track.file.path, paths[0])
          t.equal(track.tags.artist, 'The Necks')
          t.equal(track.tags.album, 'Open')
          t.equal(track.tags.title, 'Open')
          t.equal(track.date, '2012-01-20')
          t.equal(track.index, 1)
          t.end()
        },
        function (er) {
          t.ifError(er, 'shouldn\'t have failed to read')
          t.end()
github pjshumphreys / querycsv / env / c64 / build-c64a.js View on Github external
function splitUpFunctions(filename, callback, append) {
  console.log('splitUpFunctions');

  var j;

  var lineReader = readline.createInterface({
    input: fs.createReadStream(filename+'.s')
  });

  var data = fs.createWriteStream('data.s', {
    flags: append?'a':'w'
  });

  var rodataOutputStreams = [];

  var code = fs.createWriteStream(filename+'_code.s');

  var functionOutputStreams = [];
  var activeStream = code;
  var rodataType = 0;

  lineReader.on('line', function(line) {
    var name;
github CodeJockey / node-ninja / lib / build.js View on Github external
mkdirp(buildDir, function (err, isNew) {
      if (err) return callback(err)
      log.verbose('"' + buildType + '" dir needed to be created?', isNew)
      var rs = fs.createReadStream(archNodeLibPath)
        , ws = fs.createWriteStream(buildNodeLibPath)
      log.verbose('copying "' + release.name + '.lib" for ' + arch, buildNodeLibPath)
      rs.pipe(ws)
      rs.on('error', callback)
      ws.on('error', callback)
      rs.on('end', doBuild)
    })
  }
github jprichardson / node-fs-extra / lib / copy / copy.js View on Github external
function copyFileFallback (srcStat, src, dest, opts, cb) {
  const rs = fs.createReadStream(src)
  rs.on('error', err => cb(err)).once('open', () => {
    const ws = fs.createWriteStream(dest, { mode: srcStat.mode })
    ws.on('error', err => cb(err))
      .on('open', () => rs.pipe(ws))
      .once('close', () => setDestModeAndTimestamps(srcStat, dest, opts, cb))
  })
}
github nullivex / nodist / bin / node_modules / npm / lib / cache.js View on Github external
mkdir(path.dirname(tmp), function (er) {
    if (er) return cb(er)
    var from = fs.createReadStream(p)
      , to = fs.createWriteStream(tmp)
      , errState = null
    function errHandler (er) {
      if (errState) return
      return cb(errState = er)
    }
    from.on("error", errHandler)
    to.on("error", errHandler)
    to.on("close", function () {
      if (errState) return
      log.verbose("chmod", tmp, npm.modes.file.toString(8))
      fs.chmod(tmp, npm.modes.file, function (er) {
        if (er) return cb(er)
        addTmpTarball(tmp, name, shasum, cb)
      })
    })
github SAP / ui5-fs / lib / adapters / FileSystem.js View on Github external
options.createStream = function() {
							return fs.createReadStream(fsPath);
						};
					}
github release-it / release-it / lib / globcp.js View on Github external
return mkdirAsync(path.dirname(target)).then(() => new Promise((resolve, reject) => {
      const is = fs.createReadStream(source),
        os = fs.createWriteStream(target);
      is.pipe(os);
      os.on('close', error => {
        if(error) {
          reject(error);
        }
        resolve(target);
      });
    }));
  }