use of org.apache.commons.vfs2.provider.local.LocalFile in project spoofax by metaborg.
the class ResourceService method localFile.
@Override
public File localFile(FileObject resource, FileObject dir) {
if (resource instanceof LocalFile) {
return FileUtils.toFile(resource);
}
final File localDir = localPath(dir);
if (localDir == null) {
throw new MetaborgRuntimeException("Replication directory " + dir + " is not on the local filesystem, cannot get local file for " + resource);
}
try {
dir.createFolder();
final FileObject copyLoc;
if (resource.getType() == FileType.FOLDER) {
copyLoc = dir;
} else {
copyLoc = dir.resolveFile(resource.getName().getBaseName());
}
copyLoc.copyFrom(resource, new AllFileSelector());
return localDir;
} catch (FileSystemException e) {
throw new MetaborgRuntimeException("Could not get local file for " + resource, e);
}
}
Aggregations