File
@api private
176948
function File (name, path, type) {
  EventEmitter.call(this);

  this.name = name;
  this.path = path;
  this.type = type;
  this.size = 0;
  this.root = null;
  this.id = null;
  this.lastModified = new Date;
}
710145
function(file) {
			var id = typeof(file) === 'string' ? file : file.id;

			for (var i = files.length - 1; i >= 0; i--) {
				if (files[i].id === id) {
					return this.splice(i, 1)[0];
				}
			}
		}
574208
function getFilepath(fun, file) {
  		if(typeof(fun) == "function"){
  			return fun(file);
  		}
  
  		return common.tokenizePath(fun, {
  			filepath: file.subpath,
  			filename: file.filename,
  			hash: file.getHash()
  		});
  	}
949287
function makeDirGetFile(file) {
    return function (filename, cb) {
        fs.readFile(file + filename, function (err, buf) {
            if (err) {
                return cb(err);
            }

            parseJSON(buf, cb);
        });
    };
}
397049
function parseFile (file, content) {
  let type = getParseType(file)

  debug('parse file: file = %s, parseType = %s', file, type)

  if (type in parser) {
    if (typeof content !== 'string') {
      content = fs.readFileSync(file, 'utf8')
    }

    return parser[type](content)
  }
}
228172
function() {
  // Path to apis.js file
  var apis_js = path.join(__dirname, '../src', 'apis.js');
  // Create content
  // Use json-stable-stringify rather than JSON.stringify to guarantee
  // consistent ordering (see http://bugzil.la/1200519)
  var content = "/* eslint-disable */\nmodule.exports = " + stringify(apis, {
    space: '  '
  }) + ";";
  fs.writeFileSync(apis_js, content, {encoding: 'utf-8'});
}
376172
function(file, opt)
{
  //Check the file
  if(typeof file !== 'string'){ throw new Error('Missing file argument'); return null; }

  //Check the options
  if(typeof opt === 'undefined'){ var opt = {}; }

  //Save the file name
  this._file = file;

  //Check the encoding option
  this._encoding = (typeof opt.encoding === 'undefined') ? 'utf8' : opt.encoding.toString();

  //Check the chunk option
  this._chunk = (typeof opt.chunk === 'undefined') ? 10240 : opt.chunk;

  //Check the line break option
  this._endl = (typeof opt.endl === 'undefined') ? 0x0a : opt.endl;

  //Check the emptylines option
  this._emptyLines = (typeof opt.emptyLines === 'undefined') ? true : opt.emptyLines;

  //File object
  this._fd = null;

  //Actual position
  this._position = (typeof opt.start === 'undefined') ? 0 : opt.start;

  //Line count
  this._count = 0;

  //Events
  this._events = {};

  //Return this
  return this;
}
579307
function (file) {
    this.src = file.src || {};
    if (this.path) {
      this.src.path = this.path;
    }
    if (Buffer.isBuffer(this.contents)) {
      this.content = this.contents.toString();
    }
    if (this.content) {
      this.options.orig = this.content;
    }

    // ensure that `file` has `path` and `content` properties
    this.validate(file);

    this.options.orig = file.content;
    this.options.plural = this.collection.options.plural;
    this.options.handled = this.options.handled = [];

    this.src = file.src || {};
    this.src.path = this.src.path || this.path;

    // add non-emumerable properties
    this.defineOption('route', this.options.route);
    this.define('_callbacks', this._callbacks);
    file.__proto__ = this;
    file.path = this.path;

    // handle `onLoad` middleware routes
    this.app.handle('onLoad', file);
  }
420712
function fileClosed(file) {
        if (!file) {
            return;
        }
        var language = LanguageManager.getLanguageForPath(file._path),
            size = -1;

        function _sendData(fileSize) {
            var subType = "";

            if(fileSize/1024 <= 1) {

                if(fileSize < 0) {
                    subType = "";
                }
                if(fileSize <= 10) {
                    subType = "Size_0_10KB";
                } else if (fileSize <= 50) {
                    subType = "Size_10_50KB";
                } else if (fileSize <= 100) {
                    subType = "Size_50_100KB";
                } else if (fileSize <= 500) {
                    subType = "Size_100_500KB";
                } else {
                    subType = "Size_500KB_1MB";
                }

            } else {
                fileSize = fileSize/1024;
                if(fileSize <= 2) {
                    subType = "Size_1_2MB";
                } else if(fileSize <= 5) {
                    subType = "Size_2_5MB";
                } else {
                    subType = "Size_Above_5MB";
                }
            }

            sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_CLOSE + language._name + subType,
                                commonStrings.USAGE,
                                commonStrings.FILE_CLOSE,
                                language._name.toLowerCase(),
                                subType
                             );
        }

        file.stat(function(err, fileStat) {
            if(!err) {
                size = fileStat.size.valueOf()/1024;
            }
            _sendData(size);
        });
    }
657236
function writeFile(file, contents) {
	return new Promise(
		(resolve, reject) => {
			fs.writeFile(
				file, contents, error => {
					if (error) {
						reject(error);
					} else {
						// console.log('writeFile', [file, contents]);
						resolve(contents);
					}
				}
			)
		}
	);
}
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()));
				});

			}

		}
1025549
function encodeFileToJson(file) {
    var filePath = file.getPath();
    if (!filePath) {
        return undefined;
    }

    return {
        path: filePath,
        mtime: file.getMTime(),
        type: file.getType()
    };
}
1180100
def acts_as_file(params = {})
      self.class_eval do
        unless method_defined?(:save_with_file)
          define_method(:save_with_file) do |*args|
            params.each do |field, filename_instance_method|
              field_name = :"@#{field}"
              filename = filename_instance_method.bind(self).call
              content  = self.instance_variable_get(field_name)
              if filename and content
                dirname = File.dirname(filename)
                FileUtils.mkdir_p(dirname) unless Dir.exist?(dirname)
                File.open(filename, 'w') do |f|
                  f.flock(File::LOCK_EX) # inter-process locking
                  f.sync = true
                  f.write(content)
                  f.flush
                end
              end
            end
            save_without_file(*args)
          end
          define_method(:save) {|*args| } unless method_defined?(:save)
          alias_method :save_without_file, :save
          alias_method :save, :save_with_file

          params.each do |field, filename_instance_method|
            field_name = :"@#{field}"
            define_method("#{field}=") do |content|
              self.instance_variable_set(field_name, content)
            end
          end

          params.each do |field, filename_instance_method|
            field_name = :"@#{field}"
            define_method(field) do |offset = nil, length = nil|
              if offset || length
                # does not cache in this way
                filename = filename_instance_method.bind(self).call
                return nil unless filename
                return nil unless File.exist?(filename)
                File.open(filename) do |file|
                  file.seek(offset) if offset
                  file.read(length)
                end
              else
                content = self.instance_variable_get(field_name)
                return content if content
                # if (self.updated_at.nil? or File.mtime(filename) > self.updated_at)
                filename = filename_instance_method.bind(self).call
                return nil unless filename
                return nil unless File.exist?(filename)
                self.instance_variable_set(field_name, File.read(filename))
              end
            end
          end

          define_method(:destroy_with_file) do
            params.each do |field, filename_instance_method|
              field_name = :"@#{field}"
              filename = filename_instance_method.bind(self).call
              File.unlink(filename) if File.exist?(filename)
            end
            destroy_without_file
          end
          define_method(:destroy) {} unless method_defined?(:destroy)
          alias_method :destroy_without_file, :destroy
          alias_method :destroy, :destroy_with_file
        end
      end
    end
261660
function(file) {
      return {
        name: file.name,
        size: file.size,
        lastModifiedDate: file.lastModifiedDate
      };
    }
1102660
private static function file()
    {
        $files = ['File', 'Filesystem'];
        $folder = static::$root.'Filesystem'.'/';

        self::call($files, $folder);

        $files = ['FileNotFoundException', 'DirectoryNotFoundException'];
        $folder = static::$root.'Filesystem/Exceptions'.'/';

        self::call($files, $folder);
    }
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);

				}

			}

		}
382919
function fileToObject(file) {
  return {
    lastModified: file.lastModified,
    lastModifiedDate: file.lastModifiedDate,
    name: file.filename || file.name,
    size: file.size,
    type: file.type,
    uid: file.uid,
    response: file.response,
    error: file.error,
    percent: 0,
    originFileObj: file
  };
}