methods 
Async filesToFile
@param {Array} files : files to read
@param {string} target : file to write in
@param {string} separator : files separator
@param {function|null} callback : operation's result
@returns {void}
557835
function _filesToFile (files, target, separator, callback) {

			if ("undefined" === typeof files) {
				throw new ReferenceError("missing \"files\" argument");
			}
				else if ("object" !== typeof files || !(files instanceof Array)) {
					throw new TypeError("\"files\" argument is not an Array");
				}
			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 ("undefined" === typeof callback && "undefined" === typeof separator) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof separator) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				const _target = target.trim();

				if ("" === _target) {
					throw new Error("\"target\" argument is empty");
				}
				else {

					const _callback = "undefined" === typeof callback ? separator : callback;

					Promise.resolve().then(() => {
						return isFileProm(_target);
					}).then((exists) => {

						return !exists ? Promise.resolve() : new Promise((resolve, reject) => {

							fs.unlink(_target, (err) => {
								return err ? reject(err) : resolve();
							});

						});

					}).then(() => {

						if (!files.length) {

							return new Promise((resolve, reject) => {

								fs.writeFile(_target, "", (err) => {
									return err ? reject(err) : resolve();
								});

							});

						}
						else {

							return filesToStreamProm(files, "string" === typeof separator ? separator : " ").then((readStream) => {

								return new Promise((resolve, reject) => {

									let error = false;
									readStream.once("error", (_err) => {
										error = true; reject(_err);
									}).pipe(fs.createWriteStream(_target, { "flags": "a" }).once("error", (_err) => {
										error = true; reject(_err);
									}).once("close", () => {

										if (!error) {
											resolve();
										}

									}));

								});

							});

						}

					}).then(() => {
						_callback(null);
					}).catch(_callback);

				}

			}

		}
187104
function unpack(filename, callback, entryCallback) {
    var input = fs.createReadStream(filename, { flags: 'r', encoding: null }),
        files = {},
        dir = path.dirname(filename),
        returned = false,
        to = null;

    // Finishs the unpack if all files are done
    function maybeFinish() {
        if (to !== null) clearTimeout(to);
        to = setTimeout(function() {
            var alldone = true;
            var names = Object.keys(files);
            for (var i=0; i<names.length; i++) {
                if (!files[names[i]]["done"]) {
                    alldone = false;
                    break;
                }
            }
            if (alldone && !returned) {
                returned = true;
                callback(null);
            }
        }, 1000);
    }

    input.pipe(zlib.createGunzip()).pipe(tar.Parse()).on("entry", function(entry) {
        if (entryCallback) entryCallback(entry);
        if (entry["type"] == 'File') {
            files[entry["path"]] = fs.createWriteStream(path.join(dir, entry["path"]), { flags: 'w', encoding: null });
            entry.pipe(files[entry["path"]]);
            entry.on("end", function() {
                files[entry["path"]].end();
                files[entry["path"]]["done"] = true;
                maybeFinish();
            });
        } else if (entry["type"] == "Directory") {
            try {
                fs.mkdirSync(path.join(dir, entry["path"]));
            } catch (e) {
                if (!fs.existsSync(path.join(dir, entry["path"]))) {
                    if (!returned) {
                        returned = true;
                        callback(e);
                    }
                }
            }
        }
    }).on("error", function(e) {
        if (!returned) {
            returned = true;
            callback(e);
        }
    });
}
860968
function (src, target) {
  /*
   * Copy a file from one path relative to the src, to another relative to the
   * target.
   * @param {String} from - the path to copy from, relative to the src.
   * @param {String} to - the path to copy to.
   * @return {Promise} - promise to copy
   */
  this.copy = function (from, to) {
    return copy(path.resolve(src, from), path.resolve(target, to))
  }

  this.src = {
    /*
     * The source path.
     */
    path: _.clone(src),

    /*
     * Read a file, relative to the source.
     * @param {String} from - the path to read from, relative to the source.
     * @return {Promise} - a promise to return the file's content.
     */
    read: function (from) {
      return read(path.resolve(src, from))
    }

  }

  this.target = {
    /*
     * The target path.
     */
    path: _.clone(target),

    /*
     * Copy a file from one path to another, relative to the target.
     * @param {String} from - the path to copy from, relative to the target.
     * @param {String} to - the path to copy to relative to the target.
     * @return {Promise} - promise to copy
     */
    copy: function (from, to) {
      return copy(path.resolve(target, from), path.resolve(target, to))
    },

    /*
     * Read a file, relative to the target.
     * @param {String} from - the path to read from, relative to the target.
     * @return {Promise} - a promise to return the file's content.
     */
    read: function (from) {
      return read(path.resolve(target, from))
    },

    /*
     * Write a file to a path, optionally with ejs locals, relative to the
     * target.
     * @param {String} to - the path to write to, relative to the target.
     * @param {String} what - the content to write, relative to the target.
     * @param {Object} locals - object to pass as locals to ejs.
     * @return {String} - the contents of the file.
     */

    write: function (to, what, locals) {
      return write(path.resolve(target, to), what, locals)
    },

    /*
     * Rename a file, relative to the target.
     * @param {String} from - the path to the file, relative to the target.
     * @param {String} to - the new path to the file, relative to the target.
     * @return {Promise} - a promise to rename the file.
     */

    rename: function (from, to) {
      return rename(path.resolve(target, from), path.resolve(target, to))
    },

    /*
     * Remove files, relative to the target.
     * @param {String[]} what - the path(s) to read from, relative to the target.
     * @return {Promise} -  a promise to remove the file
     */
    remove: function (what) {
      return remove(target, what)
    },

    /*
     * Execute a child process at the specified working directory, relative to
     * the target.
     * @param {String} cmd - the command to run.
     * @param {string} cwd - the working directory, relative to the target
     * @return {Promise} - a promise for the standard out.
     */
    exec: function (cmd, cwd) {
      return execute(cmd, cwd ? path.resolve(target, cwd) : target)
    }
  }
}
150105
function(callback) {

			fs.appendFileSync(outputFile,"\r\n")
			fs.appendFileSync(outputFile,"    return puglatizer;\r\n")
			fs.appendFileSync(outputFile,"}));\r\n")
			return callback()
		}
179452
function foreachInDir (dirpath, fnc, done) {
	// Read the files
	fs.readdir(dirpath, function (err, files) {
		// Return error
		if (err) {
			return done(err);
		}

		// Process each file
		parallel(files.map(function (f) {
			return fnc.bind(null, f);
		}), done);
	});
}
861760
function( files, options, callback ) {
	if ( !Array.isArray( files ) ) {
		files = [files];
	}
	if ( typeof options === 'function' ) {
		callback = options;
		options = null;
	} else if ( typeof options === 'string' ) {
		options = { msg: options };
	}
	options = options || {};
	addExtraOptions( [ 'quiet', 'depth', 'msg' ], options );
	executeSvn( [ 'commit' ].concat( files ), options, callback );
}
415531
function processContent(target, opt, tagsRegExp, listOfFiles) {
	let targetContent = String(target.contents);
	const targetPath = target.path;
	const files = extractFilePaths(targetContent, targetPath, opt, tagsRegExp);

	// recursively process files
	files.forEach(function (fileData) {
		if (listOfFiles.indexOf(fileData.file.path) !== -1) {
			throw error("Circular definition found. File: " + fileData.file.path + " referenced in a child file.");
		}
		listOfFiles.push(fileData.file.path);
		const content = processContent(fileData.file, opt, tagsRegExp, listOfFiles);
		listOfFiles.pop();

		targetContent = inject(targetContent, String(content), opt, fileData.tags);
	});
	if (listOfFiles.length === 1 && !opt.quiet && files.length) {
		log(
			colors.cyan(files.length.toString()) +
			' partials injected into ' +
			colors.magenta(targetPath) +
			'.');
	}
	return new Buffer.from(targetContent);
}
534694
async function(filename, compress, result) {
  const content = JSON.stringify(result);

  const data = compress ? await gzip(content) : content;
  return await writeFile(filename + (compress ? ".gz" : ""), data);
}
2004
function FileClient(serviceRegistry, filter) {
		var _patterns;
		var _services;
		var _names;

		EventTarget.attach(this);
		/* @callback */
		function _noMatch(loc) {
			var d = new Deferred();
			d.reject(messages["No Matching FileService for location:"] + loc);
			return d;
		}

		var _fileSystemsRoots = [];
		var _allFileSystemsService = {
			/* @callback */
			fetchChildren: function() {
				var d = new Deferred();
				d.resolve(_fileSystemsRoots);
				return d;
			},
			/* @callback */
			createWorkspace: function() {
				var d = new Deferred();
				d.reject(messages["no file service"]);
				return d;
			},
			/* @callback */
			loadWorkspaces: function() {
				var d = new Deferred();
				d.reject(messages['no file service']);
				return d;
			},
			/* @callback */
			loadWorkspace: function(loc) {
				var d = new Deferred();
				window.setTimeout(function() {
					d.resolve({
						Directory: true,
						Length: 0,
						LocalTimeStamp: 0,
						Name: messages["File Servers"],
						Location: "/",
						Children: _fileSystemsRoots,
						ChildrenLocation: "/"
					});
				}, 100);
				return d;
			},
			/* @callback */
			read: function(loc) {
				if (loc === "/") {
					return this.loadWorkspace(loc);
				}
				return _noMatch(loc);
			},
			/**
			 * @description Computes the project context from the given location
			 * @param {String} context The resource context to find the project for
			 * @since 14.0
			 */
			getProject: _noMatch,
			search: _noMatch,
			createProject: _noMatch,
			createFolder: _noMatch,
			createFile: _noMatch,
			deleteFile: _noMatch,
			moveFile: _noMatch,
			copyFile: _noMatch,
			write: _noMatch
		};

		/**
		 * @description Initialize the service
		 * @private
		 */
		function init() {
			if (_services) { return; }
			_patterns = [];
			_services = [];
			_names = [];

			var allReferences = serviceRegistry.getServiceReferences("orion.core.file"); //$NON-NLS-1$
			var _references = allReferences;
			if (filter) {
				_references = [];
				for(var i = 0; i < allReferences.length; ++i) {
					if (filter(allReferences[i])) {
						_references.push(allReferences[i]);
					}
				}
			}
			_references.sort(function (ref1, ref2) {
				var ranking1 = ref1.getProperty("ranking") || 0; //$NON-NLS-1$
				var ranking2 = ref2.getProperty("ranking")  || 0; //$NON-NLS-1$
				return ranking1 - ranking2;
			});
			for(var j = 0; j < _references.length; ++j) {
				_fileSystemsRoots[j] = {
					Directory: true,
					Length: 0,
					LocalTimeStamp: 0,
					Location: _references[j].getProperty("top"), //$NON-NLS-1$
					ChildrenLocation: _references[j].getProperty("top"), //$NON-NLS-1$
					Name: _references[j].getProperty("Name") || _references[j].getProperty("NameKey") //$NON-NLS-1$ //$NON-NLS-2$
				};

				var filetop = _references[j].getProperty("top"); //$NON-NLS-1$
				var patternStringArray = _references[j].getProperty("pattern") || (filetop ? filetop.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : ""); //$NON-NLS-1$ //$NON-NLS-2$
				if (!Array.isArray(patternStringArray)) {
					patternStringArray = [patternStringArray];
				}
				var patterns = [];
				for (var k = 0; k < patternStringArray.length; k++) {
					var patternString = patternStringArray[k];
					if (patternString[0] !== "^") {
						patternString = "^" + patternString;
					}
					patterns.push(new RegExp(patternString));
				}
				_patterns[j] = patterns;
				_services[j] = serviceRegistry.getService(_references[j]);
				_names[j] = _references[j].getProperty("Name") || _references[j].getProperty("NameKey"); //$NON-NLS-1$ //$NON-NLS-2$
			}
		}

		/**
		 * @description Returns the index of the service for the given item location
		 * @function
		 * @private
		 * @param {String} itemLocation
		 * @returns returns
		 */
		this._getServiceIndex = function(itemLocation) {
			init();
			// client must specify via "/" when a multi file service tree is truly wanted
			if (itemLocation === "/") {
				return -1;
			} else if (!itemLocation || itemLocation.length && itemLocation.length === 0) {
				// TODO we could make the default file service a preference but for now we use the first one
				return _services[0] ? 0 : -1;
			}
			for(var i = 0; i < _patterns.length; ++i) {
				for (var j = 0; j < _patterns[i].length; j++) {
					if (_patterns[i][j].test(itemLocation)) {
						return i;
					}
				}
			}
			throw new Error(i18nUtil.formatMessage(messages['NoFileSrv'], itemLocation));
		};
		/**
		 * Returns the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @returns {FileClient} The service for the given item
		 */
		this._getService = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService : _services[i];
		};
		/**
		 * Returns the name of the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @return {String} The name of this file service
		 */
		this._getServiceName = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService.Name : _names[i];
		};
		/**
		 * Returns the root url of the file service managing this location
		 * @param {String} itemLocation The location of the item
		 * @private
		 * @return {String} The root URL of the given item
		 */
		this._getServiceRootURL = function(itemLocation) {
			var i = this._getServiceIndex(itemLocation);
			return i === -1 ? _allFileSystemsService.Location : _fileSystemsRoots[i].Location;
		};

		this._frozenEvent = {type: "Changed"};
		this._eventFrozenMode = false;

		serviceRegistry.registerService("orion.core.file.client", this); //$NON-NLS-1$
	}
1012612
function (files) {
        for (var i = 0; i < files.length; i++) {
          let f = files[i]
          console.log(' meeting: Filename: ' + f.name + ', type: ' + (f.type || 'n/a') +
            ' size: ' + f.size + ' bytes, last modified: ' +
            (f.lastModifiedDate ? f.lastModifiedDate.toLocaleDateString() : 'n/a')
          ) // See e.g. https://www.html5rocks.com/en/tutorials/file/dndfiles/

          // @@ Add: progress bar(s)
          var reader = new FileReader()
          reader.onload = (function (theFile) {
            return function (e) {
              var data = e.target.result
              console.log(' File read byteLength : ' + data.byteLength)
              var filename = encodeURIComponent(theFile.name)
              var contentType = theFile.type
              uploadFileToContact(filename, contentType, data)
            }
          })(f)
          reader.readAsArrayBuffer(f)
        }
      }
1088558
function concatenateAndWriteFile(files, destination, separator) {
			if (!destination || !files || !files.length) return;

			files = _.map(files, process);

			var src = files.join(separator || grunt.util.linefeed);
			grunt.file.write(destination, src);
			grunt.log.writeln('File ' + destination.cyan + ' created.');
		}
920746
function(callback) {
		// TODO: don't wait until the end. Instead, emit immediately upon finding the template

		if (!templateFile) throw new Error('template not found in stream');

		templateFile.data = templateFile.data || {};

		files.forEach(function(file) {
			var newFile = templateFile.clone();

			newFile.data.file = file;
			newFile.path = file.path;

			this.push(newFile);
		}, this);

		callback();
	}
559510
function _directoryToStream (directory, separator, callback) {

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

			else if ("undefined" === typeof callback && "undefined" === typeof separator) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof separator) {
					throw new TypeError("\"callback\" argument is not a function");
				}

			else {

				extractFiles(directory, (err, files) => {
					const _callback = "undefined" === typeof callback ? separator : callback;
					return err ? _callback(err) : filesToStream(files, separator, _callback);
				});

			}

		}
1305093
function writeFile(callback) {
        var s = JSON.stringify(images);

        fs.writeFile('imageData.json', s, function (err) {
          if (err) return console.log(err);
          else
            { 
            console.log("success");
            if (callback) callback.call(this, images);
            }
        });


    }
668115
function addFileToQueue(filename, callback){
  if (processingPaths[filename]) {
    if (typeof callback == 'function')
      processingPaths[filename].unshift(callback);

    return;
  }

  processingPaths[filename] = typeof callback == 'function'
    ? [callback].concat(readCallbacks)
    : readCallbacks.slice();

  if (readingCount < READ_LIMIT)
    readFile(filename);
  else
  {
    logMsg('fs', relativePath(filename) + ' ' + chalk.yellow('(add file to queue)'), true);
    filesToRead.push(filename);
  }
}
1307035
function(callback){
    var result,
        i;

    if(!files || files.length === 0){
        return callback(null, true);
    }

    output("Processing queries...");

    for(i=0; i<files.length; i++){
        while((result = cqlRegex.exec(files[i])) !== null) {
            batchQueries.push(result[1].replace(/\s+/g, ' ').trim());
        }
    }

    callback(null, true);
}
792455
function File(from, to) {
	var cached, dirname, external, local, source, resolved;

	resolved = _resolve(from, to);

	if (cached = cache[resolved]) {
		return cached;
	}

	if (!fs.existsSync(resolved)) {
		throw new Error('File "' + resolved + '" not found');
	}

	this.path = resolved;

	dirname = path.dirname(resolved);
	local = this.local = {};
	external = this.external = [];
	source = this.source = fs.readFileSync(resolved);

	each(detective(source), function(to) {
		if (~to.indexOf('/')) {
			local[to] = _resolve(dirname, to)
		}
		else {
			external.push(to);
		}
	});

	cache[resolved] = this;
}