/*
If the file exists, and definitely doesn't end in a newline.
14858
private function needsInitialNewline($path)
    {
        $result = false;
        if (! file_exists($path)) {
            return $result;
        }
        $fh = fopen($path, 'r');
        if ($fh === false) {
            return $result;
        }
        if (fseek($fh, -1, SEEK_END) === 0) {
            $lastChar = fgetc($fh);
            if ($lastChar !== "\n" && $lastChar !== "\r") {
                $result = true;
            }
        }
        fclose($fh);
        return $result;
    }
979741
def _HasOOOWrite(self, path):
    """"""
    # Check the sizes of each path before the current one.
    size = tf.io.gfile.stat(path).length
    old_size = self._finalized_sizes.get(path, None)
    if size != old_size:
      if old_size is None:
        logger.error('File %s created after file %s even though it\'s '
                         'lexicographically earlier', path, self._path)
      else:
        logger.error('File %s updated even though the current file is %s',
                         path, self._path)
      return True
    else:
      return False
39486
function hasFileType(file, fileExt) {
  file = path.basename(file);
  var ext = path.extname(file);
  do {
    if (ext === fileExt) {
      return true;
    } else {
      file = path.basename(file, ext);
      ext = path.extname(file);
    }
  } while (ext);
  return false;
}
763571
function findFirstFileMatchingAfterNext($ns, $name, $filename) {
		$nextPtr = \strrpos($ns, '\\next\\');

		// due to the way the syntax works, the namespace before the keyword
		// next is implied from the file namespace so it's always a complete
		// namespace rather then a partial one
		$skipNamespace = substr($ns, 0, $nextPtr + 1);

		$targetNs = substr($ns, $nextPtr + 6); // strlen('\\next\\') = 6

		$skipped = false;
		foreach ($this->state['modules'] as $module) {

			if ( ! $skipped) {
				if ($module['namespace'] == $skipNamespace) {
					$skipped = true;
				}

				continue;
			}

			if ( ! $module['enabled']) {
				continue;
			}

			if (\strripos($module['namespace'], $targetNs) !== false) {
				$targetfile = $module['path'].'/src/'.$filename.'.php';
				if ($this->file_exists($targetfile)) {
					$target = $module['namespace'].$name;
					return [ $targetfile, $module['namespace'], $target ];
				}
			}
		}

		return null; // failed to match anything
	}
307096
async function fileExists(path) {
  try {
    const stats = await stat(path);
    return stats.isFile() ? true : false;
  } catch (err) {
    return false;
  }
}
127921
def exists(self, path, **kwargs):
        """"""
        try:
            self.get_file_status(path, **kwargs)
            return True
        except HdfsFileNotFoundException:
            return False
872281
def _file_exists(path, filename):
  """"""
  return os.path.isfile(os.path.join(path, filename))
1013416
function isIgnoringFiles(path){
    if (!ignoring_files.length) return false;

    for (var i = 0, l = ignoring_files.length; i < l; i++){
        if (minimatch(path, ignoring_files[i])) return true;
    }

    return false;
}
765880
function isFile(filePath) {
  if (!isExist(filePath)) return false;
  try {
    const stat = fs.statSync(filePath);
    return stat.isFile();
  } catch (e) {
    return false;
  }
}
382894
function exists(file, src, opts) {
	var files = opts.path.map(function (dir) {
		return path.join(dir, file);
	});

	files = globby.sync(files);

	if (!files.length) {
		throw new Error(createError(file, src, opts.path));
	}

	return files[0];
}
866082
function isFileExtension(filepath, extension) {
			return typeof filepath === 'string' && path.extname(filepath) === extension && fs.existsSync(filepath) &&
				fs.lstatSync(filepath).isFile()
				;
		}
422862
function(fileName, content) {
                return Promise()
                .then(function() {
                    var filePath = PathUtils.resolveInRoot(outputFolder, fileName);

                    return fs.exists(filePath);
                });
            }
1259391
private void setEndFileMarkerFile(String fileName) {
    int fileIndex = parseFileIndex(fileName);
    if (endFileNumber == -1) {
      // First time finding the end-marker file.
      endFileNumber = fileIndex;
      logger.atInfo().log("Found end-marker file '%s' with index %s", fileName, endFileNumber);

      // Sanity-check known filenames against the endFileNumber.
      for (String knownFile : knownFileSet) {
        int knownFileIndex = parseFileIndex(knownFile);
        Preconditions.checkState(
            knownFileIndex <= endFileNumber,
            "Found known file '%s' with index %s, which isn't less than or "
                + "equal to than endFileNumber %s!",
            knownFile, knownFileIndex, endFileNumber);
      }
    } else {
      // If we found it before, make sure the file we're looking at has the same index.
      Preconditions.checkState(fileIndex == endFileNumber,
          "Found new end-marker file '%s' with index %s but already have endFileNumber %s!",
          fileName, fileIndex, endFileNumber);
    }
  }
851261
private static void checkFile(File file) {
		if (false == file.exists()) {
			throw new UtilException("File [{}] not exist !", file.getAbsolutePath());
		}
		if (false == file.isFile()) {
			throw new UtilException("Path [{}] is not a file !", file.getAbsolutePath());
		}
	}
136101
function checkFileExistsSync(filepath){
  var flag = true;

  try {
    fs.accessSync(filepath, fs.F_OK);
  } catch(e){
    flag = false;
  }

  return flag;
}
3249
private void checkForExistence(String fileName) throws IOException {
        File file = new File(fileName);
        if (!file.exists()) {
            throw new FileNotFoundException("File with name " + fileName + " does not exist.");
        }
        if (!file.isFile()) {
            throw new IOException("Provided string does not correspond to an actual file.");
        }

    }
393077
function exists(file) {
  try {
    fs.lstatSync(file);
    return true;
  } catch (e) {
    if (e.code === 'ENOENT' || e.code === 'ENOTDIR') {
      return false;
    } else {
      throw e;
    }
  }
}