Write file to disk
@param {Object.<DittoFile>} file DittoFile
@param {Function.<Error>} callback
515172
function writeFile (file, callback) {
  fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
    if (err) callback(err);
    callback(null);
  });
}
765223
function(callback) {
      fs.readdir(args['<directory>'], function(err, files) {
        // error here means it does not exist, which is good.
        if (err || args['--force']) {
          return callback(null, args['<directory>']);
        }
        if (files.length > 0) {
          return callback(new Error(format('destination '
            + 'directory %s is not empty.', path.resolve(args['<directory>']))));
        }
        return callback(null, args['<directory>']);
      });
    }
965210
function (fp, cb) {
    if (typeof fp === 'function') {
      cb = fp;
      fp = null;
    }

    if (typeof cb !== 'function') {
      throw new Error('async `write` was called without a callback function.');
    }

    var dest = fp || this.dest.path;
    var src = this.src.path;
    var str = this.content;

    if (str) {
      lazy.write(dest, str, cb);
    } else {
      lazy.copy(src, dest, cb);
    }

    this.emit('write', dest);
    return this;
  }
1175522
function writeFile(filename, data) {
	return new Promise(
		(resolve, reject) => fs.writeFile(filename, data,
			(error) => error ? reject(error) : resolve()
		)
	);
}
1123544
function(file, callback) {
        var number = arguments[2] || 0;
        var location = url.parse(file);
        var protocol = location.protocol === 'http:' ? http : https;
        var timeoutEventId;
        var that = this;
        var REDIRECTION_MAX = 3;

        var done = function(errors, data) {
            clearTimeout(timeoutEventId);
            callback(errors, data);
        }


        var request = protocol.request({
                method: 'GET',
                host: location.host,
                hostname: location.hostname,
                path: location.path,
                port: location.port,
                headers: this.adapter.resourceRequestHeaders(file)
            }, function(res) {

                var encoding = res.headers['content-encoding'];
                var type = res.headers['content-type'];
                var statusCode = res.statusCode;
                var errors = null;

                if (/3\d\d/.test(statusCode) && res.headers.location && number < REDIRECTION_MAX) {
                    clearTimeout(timeoutEventId);
                    var file = res.headers.location;
                    number++;
                    that.loadRemoteFile(file, callback, number);
                    return;
                } else if (!/2\d\d/.test(statusCode)) {
                    errors = new Error(res.statusMessage);
                }

                if (type.indexOf('text/') !== 0) {
                    errors = new Error('only supports `text/*` resources');
                }


                if (errors) {
                    done(errors);
                } else {

                    var buffer = new Buffer([]);


                    if (encoding === 'undefined') {
                        res.setEncoding('utf-8');
                    }


                    res.on('data', function(chunk) {
                        buffer = Buffer.concat([buffer, chunk]);
                    });

                    res.on('end', function() {

                        if (encoding === 'gzip') {

                            zlib.unzip(buffer, function(errors, buffer) {
                                if (errors) {
                                    done(errors);
                                } else {
                                    done(null, buffer);
                                }
                            });

                        } else if (encoding == 'deflate') {

                            zlib.inflate(buffer, function(errors, decoded) {
                                if (errors) {
                                    done(errors);
                                } else {
                                    done(null, decoded);
                                }
                            });

                        } else {
                            done(null, buffer);
                        }

                    });

                }

            })
            .on('error', done)
            .on('timeout', function(errors) {
                request.abort();
                done(errors);
            });


        timeoutEventId = setTimeout(function() {
            request.emit('timeout', new Error('have been timeout'));
        }, this.adapter.resourceTimeout);


        request.end();

    }
749649
function onFile( error, file ) {
		if ( error ) {
			debug( 'Error encountered while attempting to read a temporary output file %s: %s', outFile, error.message );
			return done( error );
		}
		debug( 'Successfully read temporary output file: %s', outFile );
		unlink( outFile, onDelete );

		/**
		* FUNCTION: onDelete( [error] )
		*	Callback invoked upon deleting a file.
		*
		* @private
		* @param {Error} [error] - error object
		* @returns {Void}
		*/
		function onDelete( error ) {
			if ( error ) {
				debug( 'Error encountered while attempting to delete a temporary output file %s: %s', outFile, error.message );
				return done( error );
			}
			debug( 'Successfully deleted temporary output file: %s', outFile );
			done( null, file );
		} // end FUNCTION onDelete()
	}
156119
function(file) {
  console.log("✔ datafile", file)
  this.file = file
  this.tree = {name: '-*-LiveLogging-*-', children: {}, items: []}

  this.queueMessagesCount = 0
  this.flush()
}
1197339
function(callback) {
            fs.exists(file, function(exists) {
                if(!exists) {
                    rawData = file;
                    if(typeof rawData === "string") rawData = new Buffer(file);
                    return callback();
                }

                fs.readFile(file, function(err, data) {
                    if(err) return callback(err);
                    rawData = data;
                    return callback();
                });
            });
        }
1119606
function writeStatsFile(statsFilePath, statsObject, callback) { // eslint-disable-line
  if (typeof statsFilePath !== 'string') {
    return callback();
  }

  if (utils.filenameExtension(statsFilePath) !== 'json') {
    throw new Error('Your stats output file must be a JSON file (i.e. --stats ./stats.json)');
  }

  fs.writeFile(path.resolve(statsFilePath), JSON.stringify(statsObject, null, 2), (writeStatsFileError) => {
    if (writeStatsFileError) {
      throw new Error(`while writting stats JSON file ${statsFilePath}: ${writeStatsFileError}`);
    }

    callback();
  });
}
365012
function write(filename, data) {
  return Promise.fromCallback(function (done) {
    debug('write', filename);
    fs.writeFile(filename, data, done);
  });
}
225217
function writeTile(file, url, request, callback) {
  // Result of request
  let res = null;

  // FileWriteStream
  let fileStream = fs.createWriteStream(file);

  // Register finish callback of FileWriteStream
  fileStream.on('finish', () => {
    callback(null, res);
  });

  // Register error callback of FileWriteStream
  fileStream.on('error', (err) => {
    callback(err, res);
  });

  // Request object
  let req = request.get(url);

  // Register error callback of request
  req.on('error', (err) => {
    callback(err, res);
  });

  // Register response callback of request
  req.on('response', (response) => {
    res = response;
  });

  // Start download
  req.pipe(fileStream);
}
21296
function _isFile (file, callback) {

			if ("undefined" === typeof file) {
				throw new ReferenceError("missing \"file\" argument");
			}
				else if ("string" !== typeof file) {
					throw new TypeError("\"file\" argument is not a string");
				}
				else if ("" === file.trim()) {
					throw new Error("\"file\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				lstat(file, (err, stats) => {
					return callback(null, Boolean(!err && stats.isFile()));
				});

			}

		}
979046
function _copyFile (origin, target, callback) {

			if ("undefined" === typeof origin) {
				throw new ReferenceError("Missing \"origin\" argument");
			}
				else if ("string" !== typeof origin) {
					throw new TypeError("\"origin\" argument is not a string");
				}
				else if ("" === origin.trim()) {
					throw new TypeError("\"origin\" argument is empty");
				}
			else if ("undefined" === typeof target) {
				throw new ReferenceError("Missing \"target\" argument");
			}
				else if ("string" !== typeof target) {
					throw new TypeError("\"target\" argument is not a string");
				}
				else if ("" === target.trim()) {
					throw new Error("\"target\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("Missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				isFileProm(origin).then((exists) => {
					return exists ? Promise.resolve() : Promise.reject(new Error("There is no origin file \"" + origin + "\""));
				}).then(() => {

					let error = false;

					const writeStream = createWriteStream(target).once("error", (_err) => {

						error = true;
						writeStream.close();

						callback(_err);

					}).once("close", () => {
						return error ? null : callback(null);
					});

					createReadStream(origin).once("error", (_err) => {
						error = true; callback(_err);
					}).pipe(writeStream);

				}).catch(callback);

			}

		}
910946
function writeFile(namespace, fileName, fileLocation) {
  var deferred = q.defer();
  // File is already written by middleware
  deferred.resolve(fileLocation);
  return deferred.promise;
}
546807
function writeFile(filename, data) {
    return new Promise(function (fulfill, reject) {
        fs.writeFile(filename, data, function (err, res) {
            return err ? reject(err) : fulfill(res);
        });
    });
}
948814
function writeFile(cvs, data, callback) {
    if (typeof data.path !== 'string') {
      return callback(new TypeError('Invalid path type: ' + typeof data.path));
    }

    var fd, buff;

    // Write the buffer to the open file stream once both prerequisites are met.
    function writeBuffer() {
      fs.write(fd, buff, 0, buff.length, 0, function (error) {
        fs.close(fd);

        callback(error);
      });
    }

    // Create a buffer of the canvas' data.
    cvs.toBuffer(function (error, _buff) {
      if (error) return callback(error);

      buff = _buff;
      if (fd) {
        writeBuffer();
      }
    });

    // Open a stream for the file to be written.
    fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) {
      if (error) return callback(error);

      fd = _fd;
      if (buff) {
        writeBuffer();
      }
    });
  }
405750
function writeFile(file, css) {
  return new Promise((resolve, reject) => {
    fs.writeFile(file, css, err => {
      if (err) {
        return reject(err);
      }
      resolve();
    })
  });
}