use of org.fagu.fmv.soft.find.SoftProvider in project fmv by f-agu.
the class SoftLogger method logDetails.
/**
* @param formatConsumer
*/
public SoftLogger logDetails(Consumer<String> formatConsumer) {
int maxLength = getNameMaxLength() + 3;
for (Soft soft : softs) {
Founds founds = soft.getFounds();
String name = soft.getName();
SoftFound firstFound = founds.getFirstFound();
SoftProvider softProvider = soft.getSoftProvider();
if (founds.isFound()) {
toLine(startLine(maxLength, name, firstFound), softProvider, firstFound, formatConsumer);
} else {
if (founds.isEmpty()) {
toLine(startLine(maxLength, name, firstFound), softProvider, SoftFound.notFound(), formatConsumer);
} else {
int index = 0;
for (SoftFound softFound : founds) {
toLine(startLine(maxLength, 0 == index++ ? name : null, softFound), softProvider, softFound, formatConsumer);
}
}
String downloadURL = softProvider.getDownloadURL();
if (downloadURL != null && !"".equals(downloadURL.trim())) {
formatConsumer.accept(" Download " + name + " at " + downloadURL + " and add the path in your system environment PATH");
}
}
}
return this;
}
use of org.fagu.fmv.soft.find.SoftProvider in project fmv by f-agu.
the class Soft method withExecFile.
/**
* @param softName
* @return
*/
public static Soft withExecFile(File file) throws IOException {
if (!file.exists()) {
throw new FileNotFoundException(file.getAbsolutePath());
}
if (!file.isFile()) {
throw new IOException("It's not a file: " + file.getAbsolutePath());
}
Path path = file.toPath();
if (!Files.isExecutable(path)) {
throw new IOException("Cannot execute: " + file.getAbsolutePath());
}
SoftProvider softProvider = new SoftProvider(file.getName(), null) {
@Override
public SoftFoundFactory createSoftFoundFactory() {
throw new RuntimeException("Not available !");
}
};
TreeSet<SoftFound> founds = new TreeSet<>(Collections.singleton(SoftFound.found(file)));
return new Soft(new Founds(softProvider.getName(), founds, null), softProvider);
}
Aggregations