use of maspack.fileutil.FileManager in project artisynth_core by artisynth.
the class LibraryInstaller method verifyJars.
public boolean verifyJars(boolean updateLibs) throws Exception {
boolean allOK = true;
if (myJarnames.size() > 0) {
FileManager grabber = new FileManager();
grabber.setVerbosityLevel(LogLevel.ALL);
FileTransferListener listener = new DefaultConsoleFileTransferListener();
grabber.addTransferListener(listener);
// 100ms
grabber.getTransferMonitor().setPollSleep(100);
grabber.setDownloadDir(myLibDir);
grabber.setRemoteSource(myRemoteSource);
int options = (updateLibs ? FileManager.CHECK_HASH : 0);
for (String jarname : myJarnames) {
File jfile = new File(myLibDir, jarname);
if (!jfile.exists()) {
try {
grabber.getRemote(jarname);
System.out.println("Downloaded jar file " + jfile);
} catch (Exception e) {
if (isConnectionException(e)) {
throw e;
}
System.out.println("Failed to download jar file " + jfile + ":");
System.out.println(e.getMessage());
allOK = false;
}
} else if (updateLibs) {
try {
if (!grabber.equalsHash(jarname)) {
grabber.getRemote(jarname);
}
System.out.println("Updated jar file " + jfile);
} catch (Exception e) {
if (isConnectionException(e)) {
throw e;
}
System.out.println("Failed to update jar file " + jfile + ":");
System.out.println(e.getMessage());
}
}
}
}
return allOK;
}
use of maspack.fileutil.FileManager in project artisynth_core by artisynth.
the class DicomTest method build.
public void build(String[] args) throws IOException {
// download the BRAINIX dicom data if it does not already exist
String localDir = ArtisynthPath.getSrcRelativePath(this, "data/MONO2_HEART");
FileManager fileManager = new FileManager(localDir, "gz:" + dicom_url + "!/");
fileManager.setConsoleProgressPrinting(true);
// download zip file first
fileManager.setOptions(FileManager.DOWNLOAD_ZIP);
// extract
File dicomPath = fileManager.get(dicom_file);
DicomViewer dcp = new DicomViewer("Heart", dicomPath.getAbsolutePath(), null, /*check subdirectories*/
false);
addRenderable(dcp);
}
Aggregations