Run Hologram when given a stream.

@param {Object} file A Vinyl file.
@param {String} encoding The file encoding.
@param {Function} cb Called after hologram has run.
@returns {Function} Executed callback.
172938
function handleStream (file, encoding, cb) {

  let config = '';

  file.contents.on('data', chunk => {
    config += chunk;
  });

  file.contents.on('end', () => {
    config = configParser(config);
    holograph.holograph(config);
    return cb(null, file);
  });

}
392304
function readFile (file) {
    if (!isFileRegistered(file)) { return undefined; }

    fileRegistry[file].content = gruntIsFile(file) ? gruntRead(file) + '\x0A' : '';
}
66383
function(file, cb) {
  var error,
      hash   = createHash('sha1'),
      stream = fs.ReadStream(file);

  stream.on('data', function(chunk) {
    hash.update(chunk);
  });

  stream.on('error', function(e) {
    if (!error) cb(e);
    error = e;
  })

  stream.on('end', function() {
    if (!error) cb(null, hash.digest('hex'));
  });
}
817205
function watchOnFile(file, callback) {
  let lastIndex = 0
  let timer

  function read() {
    const stat = fs.statSync(file)

    if (stat.size !== lastIndex) {
      const fd = fs.openSync(file, 'r')
      const buffer = Buffer.alloc(stat.size - lastIndex)

      try {
        fs.readSync(fd, buffer, lastIndex, stat.size - lastIndex)
        const content = buffer.toString('utf8')
        lastIndex = stat.size

        callback(content)
      } catch (error) {
        // 从头读起
        lastIndex = 0
      }
    }

    timer = setTimeout(read, 200)
  }

  read()
  return function() {
    clearTimeout(timer)
  }
}
613548
function(file, enc, cb) {
      if (
        !file.isNull() &&
        !file.isDirectory() &&
        options.extensions.some(function(ext) {
          return path.extname(file.path).substr(1).toLowerCase() === ext;
        })
      ) {
        file = retina.tapFile(file, cb);
      } else {
        cb();
      }
      // Push only if file is returned by retina (otherwise it is dropped from stream)
      if (file) this.push(file);
    }
335944
function ask(file, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }
  opts = opts || {};
  var prompt = lazy.inquirer.createPromptModule();
  var fp = path.relative(process.cwd(), file.path);

  var questions = {
    name: 'action',
    type: 'expand',
    message: 'Overwrite `' + fp + '`?',
    value: 'nothing',
    choices: [{
      key: 'n',
      name: 'do not overwrite',
      value: 'skip'
    }, {
      key: 'y',
      name: 'overwrite',
      value: 'write'
    }, {
      key: 'a',
      name: 'overwrite this and all others',
      value: 'force'
    }, {
      key: 'x',
      name: 'abort',
      value: 'abort'
    }, {
      key: 'd',
      name: 'diff comparison between the current and new:',
      value: 'diff'
    }]
  };

  prompt([questions], function (answers) {
    var msg = answers.action;

    switch(answers.action) {
      case 'skip':
        cb(answers.action);
        process.exit(0);

      case 'abort':
        msg = utils.red(utils.error) + ' Aborted. No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);

      case 'diff':
        var existing = opts.existing || fs.readFileSync(fp, 'utf8');
        if (lazy.isBinary(existing) && typeof opts.binaryDiff === 'function') {
          opts.binaryDiff(existing, file.contents);
        } else {
          stringDiff(existing, file.contents.toString());
        }
        return ask(file, opts, cb);

      case 'force':
        opts.force = true;
        break;

      case 'write':
        msg = utils.green(utils.success) + ' file written to';
        opts.force = true;
        break;

      default: {
        msg = utils.red(utils.error) + utils.red(' Aborted.') + ' No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);
      }
    }

    var rel = path.relative(process.cwd(), fp);
    var filepath = utils[answers.action](rel);
    if (!opts.silent) {
      console.log(msg, filepath);
    }
    return cb(answers.action);
  });
}
590588
function transform(file, enc, cb) {
        // ignore empty files
        if (file.isNull()) {
            cb(null, file);
            return;
        }

        if (file.isStream()) {
            throw new PluginError(PLUGIN_NAME, 'Streaming not supported. particular file: ' + file.path);
        }

        logger.debug('\n\nfile.path: %s', file.path || 'fake');

        if (skipFiles(file)) {
            logger.info('skip file %s', file.path);
            cb(null, file);
            return;
        }

        var pipe = this;
        processorEngine.process(file, cb, function onErr(msg) {
            pipe.emit('error', new PluginError(PLUGIN_NAME, msg));
        });
    }
257479
function (fp, opts, cb) {
    if (typeof fp !== 'string') {
      cb = opts;
      opts = fp;
      fp = null;
    }
    if (typeof opts === 'function') {
      cb = opts;
      opts = {};
    }
    if (typeof cb !== 'function') {
      throw new Error('expected a callback function.');
    }

    var dest = this.dest(fp || this.path, opts);
    var file = { contents: this.content, path: dest };
    opts = extend({ ask: true }, this.options, opts);
    utils.detect(file, opts, function (err) {
      if (file.contents) {
        utils.write(dest, file.contents, cb);
      } else {
        this.copy(dest, cb);
      }
      return this;
    }.bind(this));
    return this;
  }
726257
function run(opts, cb){
  opts.extensions = opts.extensions ? opts.extensions + ',.jsx' : '.jsx';

  // glob-all fixes windows glob issues and provides array support
  // i.e. jsxhint ['jsx/**/*','!scripts/**/*','scripts/outlier.jsx']
  runGlob(opts.args, {nodir: true}, function(err, globbed) {
    if (err) return cb(err);

    // Reassign the globbed files back to opts.args, so it looks like we just
    // fed jshint a big list of files.
    opts.args = globbed;
    var files = jshintcli.gather(opts);

    if (opts.useStdin) {
      jsxhint.transformStream(process.stdin, jsxhintOptions, opts, cb);
    } else {
      jsxhint.transformFiles(files, jsxhintOptions, opts, cb);
    }
  });
}
470212
public static void write(CharSequence content, File file, String encoding) {
        OutputStream os = null;
        try {
            os = new FileOutputStream(file);
            PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os, encoding));
            printWriter.print(content);
            printWriter.flush();
            os.flush();
        } catch (IOException e) {
            throw E.unexpected(e);
        } finally {
            close(os);
        }
    }
169093
function run (x, cb) {
  const s = speculum(null, Echo, x)
  s.on('end', cb)
  s.on('error', cb)

  const reader = new Count({ highWaterMark: 0 }, 10)

  reader.pipe(s).resume()
}
830585
function astFromFile(options, file, cb) {
  function convertSourceFile(file, packageName, packagePath) {
    fs.readFile(file, 'utf-8', function (err, source) {
      if (err) {
        return cb(err);
      }
      var extension = path.extname(file);
      if (extension[0] === '.') {
        extension = extension.substr(1);
      }
      astFromSource(options, source, extension, function (err, ast) {
        if (err) {
          err.file = file;
          return cb(err);
        }
        if (packageName) {
          ast.package = {name: packageName, path: packagePath};
          if (packagePath[0] !== '/') {
            ast.package.path = path.join(process.cwd(), packagePath);
          }
          ast.package.originalPath = packagePath;
        }
        ast.originalPath = file;
        if (file[0] === '/') {
          ast.path = file;
        } else {
          ast.path = path.join(process.cwd(), file);
        }
        return cb(null, ast);
      });
    });
  }

  function convertPackage() {
    if (path.basename(file) === 'package.json') {
      fs.readFile(file, 'utf-8', function (err, pkgString) {
        try {
          var pkg = JSON.parse(pkgString);
          if (!pkg.main) {
            return cb(new Error(file + " has no main modules."));
          }
          var main = path.join(path.dirname(file), pkg.main);
          if (!main.match(/\.js$/)) {
            main = main + '.js';
          }
          convertSourceFile(main, pkg.name, file);
        } catch (packageParseError) {
          packageParseError.message = 'Error parsing ' + file + ' - ' + packageParseError.message;
          return cb(packageParseError);
        }
      });
    } else {
      convertSourceFile(file, null);
    }
  }

  convertPackage();
}
537140
function (file) {
                var _this = this;
                if (file) {
                    setTimeout(function () {
                        _this.processing.emit(true);
                    }, 5);
                    this.imageLoaded = false;
                    this.originalImage = file;
                    this.ngxOpenCv.cvState.subscribe(function (cvState) {
                        return __awaiter(_this, void 0, void 0, function () {
                            return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0:
                                        if (!cvState.ready)
                                            return [3 /*break*/, 2];
                                        // read file to image & canvas
                                        return [4 /*yield*/, this.loadFile(file)];
                                    case 1:
                                        // read file to image & canvas
                                        _a.sent();
                                        this.processing.emit(false);
                                        _a.label = 2;
                                    case 2: return [2 /*return*/];
                                }
                            });
                        });
                    });
                }
            }
765380
function(file, cb) {
                if (!file) return cb();

                readExtension(file, function(err, ext) {
                    // ignore errors from extension check
                    //if (err) console.error(err);

                    ext = ext || extname;

                    switch (ext.toLowerCase()) {
                    // Unzip and symlink to directory.
                    case '.zip':
                        if (nosymlink) {
                            unzip(file, function(err, file) {
                                if (err) return cb(err);
                                l.Datasource.file = file;
                                return cb();
                            });
                        } else {
                            unzip(file, function(err, file_found) {
                                if (err) return cb(err);
                                l.Datasource.file = path.join(base,
                                                      'layers',
                                                      name,
                                                      path.basename(file_found));
                                return utils.processFiles(file_found,
                                                        l.Datasource.file,
                                                        file_linking_method,
                                                        {cache:cache}, cb);
                            });
                        }
                        break;
                    case '.shp':
                        if (nosymlink) {
                            l.Datasource.file = file;
                            return cb();
                        } else {
                            l.Datasource.file =
                                path.join(base, 'layers', name, path.basename(file));
                            return utils.processFiles(file, l.Datasource.file, file_linking_method, {cache:cache}, cb);
                        }
                        break;
                    default:
                        if (nosymlink) {
                            l.Datasource.file = file;
                            return cb();
                        } else {
                            l.Datasource.file =
                                path.join(base, 'layers', name + ext);
                            return file_linking_method(file, l.Datasource.file, {cache:cache}, cb);
                        }
                        break;
                    }
                });
            }
182070
function(file, callback, quality) {
		quality = !quality?85:quality;
		
		var data = this.jpeg_encode.encode(this, quality);
		
		var fd =  this.fs.openSync(file, 'w');
		var bf = new Buffer(data);
		
		this.fs.writeSync(fd, bf, 0, bf.length);
		this.fs.closeSync(fd);
		
		if(callback) {
			callback.call(this);
		}
	}
949792
function (req, file, cb) {
            const id = guid();
            file.id = id;
            fs.writeFileSync(path.normalize(tempFolder + "/" + id + ".json"), JSON.stringify(file), "utf8");
            cb(null, id);
        }
1256363
private void scanFile(File file) {
        try {
            InplaceFileConverter fc = new InplaceFileConverter(ruleSet, progressListener);
            fc.convert(file);
        } catch (IOException exc) {
            addException(new ConversionException(exc.toString()));
        }
    }