Check if the file corresponding to model JSON/YAML or HDF5 files actually exists
and throw an explicit exception.

@param fileName File name to check for existence
@throws FileNotFoundException File not found
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.");
        }

    }
1265369
protected void save(String fileName) throws Exception {
	    configuration.save(new File(fileName));
		if (isNewState()) {
		    model.moveSessionDb(fileName);
		} else {
		    if (!this.fileName.equals(fileName)) {
		        // copy file to new fileName
		        model.copySessionDb(this.fileName, fileName);
		    }
		}
	    this.fileName = fileName;
		
    	if (! Constant.isLowMemoryOptionSet()) {
			synchronized (siteTree) {
			    saveSiteTree(siteTree.getRoot());
			}
    	}
		
		model.getDb().getTableSession().update(getSessionId(), getSessionName());
	}
1255129
public boolean exists(Path filename) throws IOException {
    try {
      return getMfs().listFiles(filename, true).hasNext();
    } catch (FileNotFoundException e) {
      return false;
    }
  }
299604
function requireJSON5(filename) {
    if ( path.extname(filename) == '' ) filename += fs.existsSync(filename + '.json5') ? '.json5' : '.json';
    try {
        return JSON5.parse(stripBOM(fs.readFileSync(filename, 'utf8')));
    }
    catch(error) {
        error.message = filename + ": " + error.message;
        throw error;
    }
}
205341
@NullSafe
  public static File assertExists(File path) throws FileNotFoundException {
    if (isExisting(path)) {
      return path;
    }

    throw new FileNotFoundException(String.format("[%1$s] was not found", path));
  }
178437
public Object source( String filename )
        throws FileNotFoundException, IOException, EvalError
    {
        return source( filename, globalNameSpace );
    }
911626
public static Exception checkFile(final File file)
	{
		Exception ex = null;
		String error = null;
		// check if the file does not exists...
		if (!file.exists())
		{
			error = "The " + file + " does not exists.";
			ex = new FileDoesNotExistException(error);
			return ex;
		}
		// check if the file is not a directory...
		if (!file.isDirectory())
		{
			error = "The " + file + " is not a directory.";
			ex = new FileIsNotADirectoryException(error);
			return ex;
		}

		final File[] ff = file.listFiles();
		// If the file is null
		if (ff == null)
		{ // it is security restricted
			error = "The " + file + " could not list the content.";
			ex = new DirectoryHasNoContentException(error);
		}
		return ex;
	}
699752
public void save() throws Exception {

        if (fileName == null || fileName.length() == 0) {
            throw new java.io.FileNotFoundException(
                Error.getMessage(ErrorCode.M_HsqlProperties_load));
        }

        String filestring = fileName + ".properties";

        save(filestring);
    }
423900
public static boolean isFileExist(final String filePathString) throws Exception {

        File f = new File(filePathString);
        return f.exists();
    }
5408
def file_exists(filename):
    
    try:
        return os.path.isfile(filename)
    except (UnicodeDecodeError, UnicodeEncodeError, ValueError):
        return False
1024773
@SuppressWarnings("unchecked") // when we cast yaml.load(fin)
  public static Map<String, Object> loadFile(String fileName) {
    Map<String, Object> props = new HashMap<>();
    if (fileName == null) {
      LOG.warning("Config file name cannot be null");
      return props;
    } else if (fileName.isEmpty()) {
      LOG.warning("Config file name is empty");
      return props;
    } else {

      // check if the file exists and also it is a regular file
      Path path = Paths.get(fileName);

      if (!Files.exists(path)) {
        LOG.fine("Config file " + fileName + " does not exist");
        return props;
      }

      if (!Files.isRegularFile(path)) {
        LOG.warning("Config file " + fileName + " might be a directory.");
        return props;
      }

      LOG.log(Level.FINE, "Reading config file {0}", fileName);

      Map<String, Object> propsYaml = null;
      try {
        FileInputStream fin = new FileInputStream(new File(fileName));
        try {
          Yaml yaml = new Yaml();
          propsYaml = (Map<String, Object>) yaml.load(fin);
          LOG.log(Level.FINE, "Successfully read config file {0}", fileName);
        } finally {
          fin.close();
        }
      } catch (IOException e) {
        LOG.log(Level.SEVERE, "Failed to load config file: " + fileName, e);
      }

      return propsYaml != null ? propsYaml : props;
    }
  }
770521
protected function setFilename($filename) {
        if (false === realpath($filename)) {
            throw new FileNotFoundException(sprintf("The file \"%s\" was not found", $filename));
        }
        $this->filename = realpath($filename);
        return $this;
    }
167847
private boolean deleteFile(String filename) throws Exception {
        if (filename == null) {
            return false;
        }
        File file = new File(storeDir, filename);
        return Files.deleteIfExists(file.toPath());
    }
247990
@Override
    public void checkRepositoryStatus() throws IOException {
        for (File f : assets) {
            if (!f.exists()) {
                throw new FileNotFoundException("Could not find " + f + " in the LooseFileRepository");
            }
        }
    }
209869
public void fileNotFound(File f) {
        if (!recentFiles.contains(f)) {
            throw new IllegalStateException("Well no wonder it wasn't found, its not in the list.");
        } else {
            recentFiles.remove(f);
        }

    }
517509
protected function checkFileExistence(/*# string */ $file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            throw new NotFoundException(
                Message::get(Message::DEFINITION_NOT_FOUND, $file),
                Message::DEFINITION_NOT_FOUND
            );
        }
    }
1312905
public boolean add(String fileName) {
      writeLock.lock();
      try {
         return filenames.add(fileName);
      } finally {
         writeLock.unlock();
      }
   }