Checks if a file exists and if it does returns it's contents.
Otherwise returns null.

@param {String} file The path to a file.

@returns {String|null} The contents of the file if it exists.
351922
function readFile(file) {

    if (file && fs.existsSync(file)) {
        return fs.readFileSync(file);
    }

    return null;
}
70881
function (file) {
    if (file.substr(file.length - 1) === '/') {
        file = file + 'index.html';
    }
    if (fss.exists(file + '.html')) {
        return file + '.html';
    } else if (fss.exists(file.replace(/\.html$/, ''))) {
        return file.replace(/\.html$/, '');
    } else if (fss.filename(file).indexOf('.') === -1 && fss.exists(file + '/index.html')) {
        return file + '/index.html';
    } else {
        return file;
    }
}
422862
function(fileName, content) {
                return Promise()
                .then(function() {
                    var filePath = PathUtils.resolveInRoot(outputFolder, fileName);

                    return fs.exists(filePath);
                });
            }
996197
function(file) {
    var data = file.data = parse(file.relative, {locales: options.locales});

    // data.locale
    data.locale || (data.locale = options.defaultLocale);

    // data.document
    if (~(options.dataExtensions || []).indexOf(data.extname)) {
      data.document = 'data';
    } else if (fm.test(file.contents.toString())) {
      data.document = 'text';
    } else {
      data.document = false;
    }

    // data.filepaths
    data.filepaths = [];
    data.filepaths.push(data.locale === options.defaultLocale ? null : data.locale);
    data.filepaths.push.apply(data.filepaths, data.dirnames);
    if (data.document) {
      data.filepaths.push(data.index ? null : data.slug);
      data.filepaths.push('index.html');
    } else {
      data.filepaths.push(data.slug + '.' + data.extname);
    }
    data.filepaths = data.filepaths.filter(function(x) { return x });

    // data.filepath
    data.filepath = path.join.apply(path, data.filepaths);

    // file.path
    file.path = path.join(file.base, data.filepath);

    return file;
  }
231343
function fileExist(fileName) {
  return new Promise((resolve, reject) => {
    fs.stat(fileName, (err, stats) => {
      if (err === null && stats.isFile()) {
        resolve(fileName);
      } else {
        resolve(false);
      }
    });
  });
}
960114
function (file) {
        if (!this.ignore(file)) {
            file = this.map(file);
            file = utils.normalize(file);
            return file;
        }
    }
950715
function isJSON (file) {
  try {
    JSON.parse(file.contents.toString());
    return true;
  } catch (err) {
    return false;
  }
}
764761
function(file) {
      var type = file.type.toLowerCase(),
        sources = file.sources;

      $.each(sources, function(tmpSource) {
        if (_support[type][tmpSource]) {
          file = file.sources[tmpSource];
          file.type = type.toUpperCase();
          return false;
        }
      });
      if (file.source) {
        return file;
      } else {
        return false;
      }
    }
368753
static function read($file)
	{
		if(file_exists($file) && is_readable($file))
			return file_get_contents($file);

		foreach(bors_dirs() as $dir)
			if(file_exists($fn = $dir.'/data/'.$file) && is_readable($fn))
				return file_get_contents($fn);

		return NULL;
	}
1340201
function(file, options) {
		file = this.absPath(file);
		var cwd = (options && options.cwd) || '';
		if (file.substring(0, cwd.length) == cwd) {
			file = file.substring(cwd.length);
			if (file.charAt(0) != '/') {
				file = '/' + file;
			}
		}

		return file;
	}
748863
public static File exists(File file) {
		Validate.notNull(file);
		if(!file.exists())
			throw new ParameterException("\""+file+"\" does not exist!");
		return file;
	}
887330
public static boolean exists(File file) {
        try {
            boolean fileExists = file.exists();
            if(!forceCaseSensitive || !fileExists) {
                return fileExists;
            }

            String absPath = canonicalize(file.getAbsolutePath());
            String canPath = canonicalize(file.getCanonicalPath());
            return fileExists && absPath.equals(canPath);
        } catch(IOException io) {
            return false;
        }
    }
1122616
function readPromise(file, defaultContent){
	return new Promise(function(resolve, reject){
		if ( exists(file) ) {
			fs.readFile(file, 'utf-8', (err, data) => err ? reject(err) : resolve(data));
		}else{
			defaultContent === undefined ? reject('file not found: ' + file) : resolve(defaultContent);
		}
	});
}
1174747
function getFileMIME(file) {
  var idx = file.lastIndexOf('.')
  var ext = idx > -1 ? file.slice(idx) : null
  if (ext) ext = ext.toLowerCase().substring(1)
  return MIMES[ext] || MIMES.txt
}
1308709
function isIgnoredFile(file) {
    if (options.ignore !== undefined) {
      var result = false;

      options.ignore.forEach(function(pattern) {
        if (minimatch(file, pattern)) {
          result = true;
          return false;
        }
      });

      return result;
    }

    return false;
  }
1319305
function(file, opts) {
	if (util.isObject(file) || util.isArray(file)) {
		return file;
	}

	var options = util.extend({
		asText: false, // true, false, 'pretty'
		javascript: false, // true, false
		scope: '', // directory to look for initial file
		variables: {
			// contains a key->value object with variables to @extends
		}
	}, opts);

	file = util.template(file, options.variables);

	/*****************************************************************************
	*  Initialize
	*****************************************************************************/

	var file_path;

	// If the file path is absolute use it
	// If not then prepend the current scope of the previous file.
	if (path.resolve(file) === path.normalize(file)) {
		file_path = path.normalize(file);
	}
	else {
		file_path = path.normalize(
			options.scope ? options.scope + '/' + file : file
		);
	}
	var class_json = parseFile(file_path, options);

	// Stores JSON objects of files that have to be merged together:
	// ["a", "b"]
	var file_list = util.isArray(class_json[indicators.EXTENDS]) ?
		class_json[indicators.EXTENDS] :
		class_json[indicators.EXTENDS] != null ?
			[ class_json[indicators.EXTENDS] ] :
			[];

	// Delete @extends from base_json to avoid infinitive recursion
	delete class_json[indicators.EXTENDS];

	// Push class_json to the path list:
	file_list.push(class_json);
	/*****************************************************************************
	*  Merge file by file
	*****************************************************************************/

	// default config for each file required:
	// set asText = false so we get an object returned
	// set scope = file's directory so there can be relative references
	var json_config = util.defaults({
		asText: false,
		scope: path.dirname(file_path),

		// _as is a hack so that we know its we are calling the function recursive
		_as: ANTI_SANITIZER
	}, options);

	// super_json is our output, start by containing first file in array
	var super_json = fromFile(file_list.shift(), json_config);

	// TODO: Figure out when to sanitize super_json hopefully we don't have to
	//   santize all returns. I'm not sure about this, and I'm not sure if we
	//   can even sanitize super_json when we return it.
	//   Is super_json used by anyone recursively?

	while (file_list.length) {
		var json = fromFile(file_list.shift(), json_config);

		merge(super_json, json);
	}

	// If this file is called from the outside eg json_merger.from...
	//   File('file_which_doesnt_extends_another_file.json')
	//   we need to sanitize the file and remove all indicators
	if (options._as != ANTI_SANITIZER) {
		super_json = util.sanitizeValue(super_json);
	}

	/*****************************************************************************
	*  Return super_json
	*****************************************************************************/
	if (options.asText) {
		return stringify(super_json, options);
	}
	else {
		return super_json;
	}
}
1172339
public static String asPath(File file) {
        if (file == null) {
            return null;
        }
        return asPath(file.getPath());
    }