protected File getFile(String path, boolean checkExists) throws StorageException {
File res;
if (this.root == null) {
throw new StorageException("The root has not been set so couldn't get a handle to {" + path + "}");
}
res = new File(this.root, path);
if (checkExists) {
if (!res.exists()) {
throw new StorageException("File {" + res.getAbsolutePath() + "} does not exists.");
}
if (!res.isFile()) {
throw new StorageException("File {" + res.getAbsolutePath() + "} exists but it's not a file.");
}
} else {
if (!res.isDirectory()) {
throw new StorageException("File {" + res.getAbsolutePath() + "} is a folder not a file.");
}
}
return res;
}