public static String getManipulatedMapScript(File scriptFile) throws IOException, MapFormatException { FileInputStream r = new FileInputStream(scriptFile); byte[] bytes = new byte[(int) scriptFile.length()]; r.read(bytes); r.close(); String mapScript = ScriptInjector.inject(new String(bytes)); return mapScript; }
private String writeCode(CodeGenVisitor generator) throws IOException, MoPaQException, MapFormatException { String outputName = options.outDir.getPath() + "/Andromeda.galaxy"; StringBufferWriter w = new StringBufferWriter(); generator.flushOutCode(w); String code = w.toString(); // Create out directory options.outDir.mkdirs(); // Write to external file BufferedWriter bw = new BufferedWriter(new FileWriter(new File(options.outDir, "Andromeda.galaxy"))); bw.write(code); bw.close(); // If we have an input map, manipulate its mapScript if (map != null || options.mapScriptIn != null) { // Write map script to output folder String mapScript; if (map != null) { mapScript = ScriptInjector.getManipulatedMapScript(map); } else { mapScript = ScriptInjector.getManipulatedMapScript(options.mapScriptIn); } BufferedWriter bw2 = new BufferedWriter(new FileWriter(new File(options.outDir, "MapScript.galaxy"))); bw2.write(mapScript); bw2.close(); // Write to map file if specified if (options.mapOut != null) { ScriptInjector.injectAndromeda(map, mapScript, code); map.save(options.mapOut); outputName = options.mapOut.getName(); } } return outputName; }
public static String getManipulatedMapScript(MoPaQ m) throws MapFormatException { String mapScript = ScriptInjector.inject(new String(m.returnFileByName("MapScript.galaxy"))); return mapScript; }