use of com.laytonsmith.PureUtilities.ZipReader in project CommandHelper by EngineHub.
the class SiteDeploy method deployLearningTrail.
/**
* Pages deployed: All files from /docs/*
*/
private void deployLearningTrail() {
generateQueue.submit(new Runnable() {
@Override
public void run() {
try {
File root = new File(SiteDeploy.class.getResource("/docs").toExternalForm());
ZipReader zReader = new ZipReader(root);
for (File r : zReader.listFiles()) {
String filename = r.getAbsolutePath().replaceFirst(Pattern.quote(zReader.getFile().getAbsolutePath()), "");
writePageFromResource(r.getName(), "/docs" + filename, r.getName() + ".html", Arrays.asList(new String[] { r.getName().replace("_", " ") }), "Learning trail page for " + r.getName().replace("_", " "));
}
} catch (IOException ex) {
Logger.getLogger(SiteDeploy.class.getName()).log(Level.SEVERE, null, ex);
}
currentGenerateTask.addAndGet(1);
}
});
totalGenerateTasks.addAndGet(1);
}
use of com.laytonsmith.PureUtilities.ZipReader in project CommandHelper by EngineHub.
the class ExampleLocalPackageInstaller method install.
private static void install(String pkg) throws IOException {
URL url = ExampleLocalPackageInstaller.class.getResource("/local_packages/" + pkg);
if (url == null) {
StreamUtils.GetSystemOut().println("\"" + pkg + "\" is not a valid package name.");
System.exit(1);
}
ZipReader reader = new ZipReader(url);
File localPackages = new File(jarFolder, "CommandHelper/LocalPackages/" + pkg);
if (localPackages.exists() && localPackages.list().length != 0) {
StreamUtils.GetSystemOut().println("The LocalPackage " + pkg + " already exists on your system, and is not empty. Are you sure you wish to possibly overwrite files? (Y/N)");
StreamUtils.GetSystemOut().print(">");
String response = new Scanner(System.in).nextLine();
if (!"Y".equalsIgnoreCase(response)) {
System.exit(0);
}
}
reader.recursiveCopy(localPackages, true);
StreamUtils.GetSystemOut().println("Local package installed at " + localPackages);
}
use of com.laytonsmith.PureUtilities.ZipReader in project CommandHelper by EngineHub.
the class Main method loadSelfVersion.
@SuppressWarnings({ "ThrowableInstanceNotThrown", "ThrowableInstanceNeverThrown" })
public static SimpleVersion loadSelfVersion() throws Exception {
File file = new File(new File(Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()), "plugin.yml");
ZipReader reader = new ZipReader(file);
if (!reader.exists()) {
throw new FileNotFoundException(String.format("%s does not exist", file.getPath()));
}
try {
String contents = reader.getFileContents();
Yaml yaml = new Yaml();
Map<String, Object> map = (Map<String, Object>) yaml.load(contents);
return new SimpleVersion((String) map.get("version"));
} catch (RuntimeException | IOException ex) {
throw new Exception(ex);
}
}
Aggregations