bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
3,240,908
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
3,240,909
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
3,240,910
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
3,240,911
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
protected void addFileSet(String path, String[] includes, String[] excludes, String relPath, List osList, ArrayList list, boolean casesensitive, int override) throws CompilerException { File test = new File(path); if (test.isDirectory()) { DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setExcludes(excludes); ds.setBasedir(new File(path)); ds.setCaseSensitive(casesensitive); ds.scan(); String[] files = ds.getIncludedFiles(); String[] dirs = ds.getIncludedDirectories(); /* Old buggy code String newRelativePath = null; String absolutBasePath = test.getParentFile().getAbsolutePath(); String absolutPath = test.getAbsolutePath(); String absolutFilePath = null; int copyPathFrom = absolutBasePath.length() + 1; for (int i = 0; i < files.length; i++) { File file = new File(absolutPath + File.separator + files[i]); absolutFilePath = file.getParentFile().getAbsolutePath(); newRelativePath = relPath + File.separator + absolutFilePath.substring(copyPathFrom); //FIX ME: the override for fileset is by default true, needs to be changed addFile(file, newRelativePath, targetOs, true, list); } */ // New working code (for files) String filePath, instPath, expPath; int pathLimit; File file; for (int i = 0; i < files.length; ++i) { filePath = path + File.separator + files[i]; expPath = relPath + File.separator + files[i]; file = new File(filePath); pathLimit = expPath.indexOf(file.getName()); if (pathLimit > 0) instPath = expPath.substring(0, pathLimit); else instPath = relPath; addFile(file, instPath, osList, override, list); } // Empty directories are left by the previous code section, so we need to // take care of them for (int i = 0; i < dirs.length; ++i) { expPath = path + File.separator + dirs[i]; File dir = new File(expPath); if (dir.list().length == 0) { instPath = relPath + File.separator + dirs[i]; pathLimit = instPath.indexOf(dir.getName()); instPath = instPath.substring(0, pathLimit); addFile(dir, instPath, osList, override, list); } } } else throw new CompilerException("\"dir\" attribute of fileset is not valid: " + path); }
3,240,912
protected void addSingleFile(File file, String targetFile, List osList, int override, ArrayList list) throws CompilerException { //System.out.println ("adding single file " + file.getName() + " as " + targetFile); PackSource nf = new PackSource(); nf.src = file.getAbsolutePath(); nf.setTargetFile (targetFile); nf.osConstraints = osList; nf.override = override; list.add(nf); }
protected void addSingleFile(File file, String targetFile, List osList, int override, ArrayList list) throws CompilerException { //System.out.println ("adding single file " + file.getName() + " as " + targetFile); PackSource nf = new PackSource(); nf.src = file.getAbsolutePath(); nf.setTargetFile (targetFile); nf.osConstraints = osList; nf.override = override; list.add(nf); }
3,240,913
protected void addSingleFile(File file, String targetFile, List osList, int override, ArrayList list) throws CompilerException { //System.out.println ("adding single file " + file.getName() + " as " + targetFile); PackSource nf = new PackSource(); nf.src = file.getAbsolutePath(); nf.setTargetFile (targetFile); nf.osConstraints = osList; nf.override = override; list.add(nf); }
protected void addSingleFile(File file, String targetFile, List osList, int override, ArrayList list) throws CompilerException { //System.out.println ("adding single file " + file.getName() + " as " + targetFile); PackSource nf = new PackSource(); nf.src = file.getAbsolutePath(); nf.setTargetFile(targetFile); nf.osConstraints = osList; nf.override = override; list.add(nf); }
3,240,914
private void debug(String s) { if (Debug.tracing())//if you are wondering what files gets added to the installer { packagerListener.packagerMsg(s); } }
private void debug(String s) { if (Debug.tracing())//if you are wondering what files gets added to the installer { packagerListener.packagerMsg(s); } }
3,240,915
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,916
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream( "/bin/langpacks/installer/" + str + ".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,917
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,918
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass().getResourceAsStream("/bin/langpacks/flags/" + str + ".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,919
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,920
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close(); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close(); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close(); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,921
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println( "ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,922
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,923
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,924
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,925
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,926
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,927
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close(); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close(); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close(); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,928
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel) iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,929
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,930
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,931
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/" + str + ".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,932
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,933
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,934
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,935
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,936
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,937
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,938
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,939
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,940
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename(); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,941
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,942
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,943
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,944
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
public void executeCompiler() throws Exception { // normalize and test: TODO: may allow failure if we require write access File base = new File(basedir).getAbsoluteFile(); if (! base.canRead() || ! base.isDirectory()) throw new CompilerException("Invalid base directory: "+base); // Usefull variables int i; String str; Iterator iter; InputStream inStream; // We get the XML data tree XMLElement data = getXMLTree(); // We get the Packager Packager packager = getPackager(); // We add the variable declaration packager.setVariables(getVariables(data)); // We add the info packager.setInfo(getInfo(data)); // We add the GUIPrefs packager.setGUIPrefs(getGUIPrefs(data)); // We add the language packs iter = getLangpacksCodes(data).iterator(); while (iter.hasNext()) { str = (String) iter.next(); // The language pack - first try to get stream directly (for standalone compiler) inStream = getClass().getResourceAsStream("/bin/langpacks/installer/"+str+".xml"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "installer" + File.separator + str + ".xml"); } packager.addLangPack(str, inStream); // The flag - try to get stream for standalone compiler inStream = getClass ().getResourceAsStream("/bin/langpacks/flags/"+str+".gif"); if (inStream == null) { inStream = new FileInputStream(Compiler.IZPACK_HOME + "bin" + File.separator + "langpacks" + File.separator + "flags" + File.separator + str + ".gif"); } packager.addResource("flag." + str, inStream); inStream.close (); } // We add the resources iter = getResources(data).iterator(); while (iter.hasNext()) { Resource res = (Resource) iter.next(); if (res.parse) { if ((res.src == null) || (res.src_is != null)) { System.err.println("ERROR: cannot parse resource from stream. (Internal error.)"); packager.addResource(res.id, res.src_is); } if (null != varMap) { File resFile = new File(res.src); FileInputStream inFile = new FileInputStream(resFile); BufferedInputStream bin = new BufferedInputStream(inFile, 5120); File parsedFile = File.createTempFile("izpp", null, resFile.getParentFile()); FileOutputStream outFile = new FileOutputStream(parsedFile); BufferedOutputStream bout = new BufferedOutputStream(outFile, 5120); VariableSubstitutor vs = new VariableSubstitutor(varMap); vs.substitute(bin, bout, res.type, res.encoding); bin.close(); bout.close(); inFile = new FileInputStream(parsedFile); packager.addResource(res.id, inFile); inFile.close(); parsedFile.delete(); } else { System.err.println("ERROR: no variable is defined. " + res.src + " is not parsed."); inStream = new FileInputStream(res.src); packager.addResource(res.id, inStream); inStream.close (); } } else { if (res.src != null) { inStream = new FileInputStream(res.src); } else { inStream = res.src_is; } packager.addResource(res.id, inStream); if (res.src != null) inStream.close (); } } // We add the native libraries iter = getNativeLibraries(data).iterator(); while (iter.hasNext()) { NativeLibrary nat = (NativeLibrary) iter.next(); inStream = new FileInputStream(nat.path); packager.addNativeLibrary(nat.name, inStream); } // We add the additionnal jar files content iter = getJars(data).iterator(); while (iter.hasNext()) packager.addJarContent((String) iter.next()); // We add the panels ArrayList panels = getPanels(data); TreeSet panelsCache = new TreeSet(); iter = getPanels(data).iterator(); while (iter.hasNext()) { Panel p = (Panel)iter.next(); // We locate the panel classes directory str = p.className; // first try to get a Jar file for standalone compiler JarInputStream panel_is = null; try { InputStream jarInStream = getClass().getResourceAsStream("/bin/panels/"+str+".jar"); if (jarInStream != null) panel_is = new JarInputStream (jarInStream); } catch (IOException e) { // for now, ignore this - try to read panel classes from filesystem panel_is = null; } if (panel_is != null) { if (panelsCache.contains(str)) continue; panelsCache.add(str); // now add files ZipEntry entry = null; while ((entry = panel_is.getNextEntry()) != null) packager.addPanelClass(entry.getName(), panel_is); } else { File dir = new File(Compiler.IZPACK_HOME + "bin" + File.separator + "panels" + File.separator + str); if (!dir.exists()) throw new Exception(str + " panel does not exist"); // We add each file in the panel folder if (panelsCache.contains(str)) continue; panelsCache.add(str); File[] files = dir.listFiles(); int nf = files.length; for (int j = 0; j < nf; j++) { if (files[j].isDirectory()) continue; FileInputStream inClass = new FileInputStream(files[j]); packager.addPanelClass(files[j].getName(), inClass); } } } // We set the panels order packager.setPanelsOrder(panels); Map storedFiles = new HashMap(); // We add the packs i = 0; //pack counter iter = getPacks(data).iterator(); while (iter.hasNext()) { Pack pack = (Pack) iter.next(); ZipOutputStream zipOut = packager.addPack(i, pack.name, pack.osConstraints, pack.required, pack.description, pack.preselected); zipOut.flush();//make sure buffers are flushed before we start counting ByteCountingOutputStream dos = new ByteCountingOutputStream(zipOut);//stream with byte counter ObjectOutputStream objOut = new ObjectOutputStream(dos); // We write the pack data objOut.writeInt(pack.packFiles.size()); Iterator iter2 = pack.packFiles.iterator(); long packageBytes = 0; while (iter2.hasNext()) { // Initialisations PackSource p = (PackSource) iter2.next(); File f = new File(p.src); FileInputStream in = new FileInputStream(f); long nbytes = f.length(); long mtime = f.lastModified(); String targetFilename = p.getTargetFilename (); // pack paths in canonical (unix) form regardless of current host o/s: if('/' != File.separatorChar) { targetFilename = targetFilename.replace(File.separatorChar, '/'); } // Writing PackFile pf = new PackFile(targetFilename, p.osConstraints, nbytes, mtime, p.override); long[] info = (long[])storedFiles.get(p.src); boolean addFile = true; if (info != null && packager.allowPackFileBackReferences()) { pf.setPreviousPackFileRef((int)info[0],info[1]); addFile = false; } objOut.writeObject(pf); objOut.flush();//make sure it is written long pos = dos.getByteCount();//get the position if (addFile) { byte[] buffer = new byte[5120]; long bytesWritten = 0; int bytesInBuffer; while ((bytesInBuffer = in.read(buffer)) != -1) { objOut.write(buffer, 0, bytesInBuffer); bytesWritten += bytesInBuffer; } if (bytesWritten != nbytes) throw new IOException ("File size mismatch when reading " + f); storedFiles.put(p.src,new long[]{i,pos}); } packageBytes += nbytes;//aldo could be not really written we still want to know size. in.close(); } packager.packAdded(i, packageBytes); // Write out information about parsable files objOut.writeInt(pack.parsables.size()); iter2 = pack.parsables.iterator(); while (iter2.hasNext()) objOut.writeObject(iter2.next()); // Write out information about executable files objOut.writeInt(pack.executables.size()); iter2 = pack.executables.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Write out information about executable files objOut.writeInt(pack.updatechecks.size()); iter2 = pack.updatechecks.iterator(); while (iter2.hasNext()) { objOut.writeObject(iter2.next()); } // Cleanup objOut.flush(); zipOut.closeEntry(); i++; } // We ask the packager to finish packager.finish(); this.compileFailed = false; }
3,240,945
protected GUIPrefs getGUIPrefs(XMLElement data) throws CompilerException { // We get the XMLElement & the values XMLElement gp = data.getFirstChildNamed("guiprefs"); Integer integer; GUIPrefs p = new GUIPrefs(); if (gp == null) return p; p.resizable = requireYesNoAttribute(gp, "resizable"); p.width = requireIntAttribute(gp, "width"); p.height = requireIntAttribute(gp, "height"); // We return the GUIPrefs return p; }
protected GUIPrefs getGUIPrefs(XMLElement data) throws CompilerException { // We get the XMLElement & the values XMLElement gp = data.getFirstChildNamed("guiprefs"); Integer integer; GUIPrefs p = new GUIPrefs(); if (gp == null) return p; p.resizable = requireYesNoAttribute(gp, "resizable"); p.width = requireIntAttribute(gp, "width"); p.height = requireIntAttribute(gp, "height"); // We return the GUIPrefs return p; }
3,240,946
protected GUIPrefs getGUIPrefs(XMLElement data) throws CompilerException { // We get the XMLElement & the values XMLElement gp = data.getFirstChildNamed("guiprefs"); Integer integer; GUIPrefs p = new GUIPrefs(); if (gp == null) return p; p.resizable = requireYesNoAttribute(gp, "resizable"); p.width = requireIntAttribute(gp, "width"); p.height = requireIntAttribute(gp, "height"); // We return the GUIPrefs return p; }
protected GUIPrefs getGUIPrefs(XMLElement data) throws CompilerException { // We get the XMLElement & the values XMLElement gp = data.getFirstChildNamed("guiprefs"); Integer integer; GUIPrefs p = new GUIPrefs(); if (gp == null) return p; p.resizable = requireYesNoAttribute(gp, "resizable"); p.width = requireIntAttribute(gp, "width"); p.height = requireIntAttribute(gp, "height"); // We return the GUIPrefs return p; }
3,240,947
protected Info getInfo(XMLElement data) throws Exception { // Initialisation Info info = new Info(); XMLElement root = requireChildNamed(data, "info"); info.setAppName(requireContent(requireChildNamed(root, "appname"))); info.setAppVersion(requireContent(requireChildNamed(root, "appversion"))); info.setAppURL(requireContent(requireChildNamed(root, "url"))); // We get the authors list XMLElement authors = root.getFirstChildNamed("authors"); if (authors != null) { Iterator iter = authors.getChildrenNamed("author").iterator(); while (iter.hasNext()) { XMLElement author = (XMLElement) iter.next(); String name = requireAttribute(author, "name"); String email = requireAttribute(author, "email"); info.addAuthor(new Info.Author(name, email)); } } // We get the java version required XMLElement javaVersion = root.getFirstChildNamed("javaversion"); if (javaVersion != null) info.setJavaVersion(javaVersion.getContent()); XMLElement uninstallInfo = root.getFirstChildNamed ("uninstaller"); if (uninstallInfo != null) info.setWriteUninstaller(validateYesNoAttribute(uninstallInfo, "write", YES)); // We return the suitable Info object return info; }
protected Info getInfo(XMLElement data) throws Exception { // Initialisation Info info = new Info(); XMLElement root = requireChildNamed(data, "info"); info.setAppName(requireContent(requireChildNamed(root, "appname"))); info.setAppVersion(requireContent(requireChildNamed(root, "appversion"))); info.setAppURL(requireContent(requireChildNamed(root, "url"))); // We get the authors list XMLElement authors = root.getFirstChildNamed("authors"); if (authors != null) { Iterator iter = authors.getChildrenNamed("author").iterator(); while (iter.hasNext()) { XMLElement author = (XMLElement) iter.next(); String name = requireAttribute(author, "name"); String email = requireAttribute(author, "email"); info.addAuthor(new Info.Author(name, email)); } } // We get the java version required XMLElement javaVersion = root.getFirstChildNamed("javaversion"); if (javaVersion != null) info.setJavaVersion(javaVersion.getContent()); XMLElement uninstallInfo = root.getFirstChildNamed("uninstaller"); if (uninstallInfo != null) info.setWriteUninstaller(validateYesNoAttribute(uninstallInfo, "write", YES)); // We return the suitable Info object return info; }
3,240,948
protected Info getInfo(XMLElement data) throws Exception { // Initialisation Info info = new Info(); XMLElement root = requireChildNamed(data, "info"); info.setAppName(requireContent(requireChildNamed(root, "appname"))); info.setAppVersion(requireContent(requireChildNamed(root, "appversion"))); info.setAppURL(requireContent(requireChildNamed(root, "url"))); // We get the authors list XMLElement authors = root.getFirstChildNamed("authors"); if (authors != null) { Iterator iter = authors.getChildrenNamed("author").iterator(); while (iter.hasNext()) { XMLElement author = (XMLElement) iter.next(); String name = requireAttribute(author, "name"); String email = requireAttribute(author, "email"); info.addAuthor(new Info.Author(name, email)); } } // We get the java version required XMLElement javaVersion = root.getFirstChildNamed("javaversion"); if (javaVersion != null) info.setJavaVersion(javaVersion.getContent()); XMLElement uninstallInfo = root.getFirstChildNamed ("uninstaller"); if (uninstallInfo != null) info.setWriteUninstaller(validateYesNoAttribute(uninstallInfo, "write", YES)); // We return the suitable Info object return info; }
protected Info getInfo(XMLElement data) throws Exception { // Initialisation Info info = new Info(); XMLElement root = requireChildNamed(data, "info"); info.setAppName(requireContent(requireChildNamed(root, "appname"))); info.setAppVersion(requireContent(requireChildNamed(root, "appversion"))); info.setAppURL(requireContent(requireChildNamed(root, "url"))); // We get the authors list XMLElement authors = root.getFirstChildNamed("authors"); if (authors != null) { Iterator iter = authors.getChildrenNamed("author").iterator(); while (iter.hasNext()) { XMLElement author = (XMLElement) iter.next(); String name = requireAttribute(author, "name"); String email = requireAttribute(author, "email"); info.addAuthor(new Info.Author(name, email)); } } // We get the java version required XMLElement javaVersion = root.getFirstChildNamed("javaversion"); if (javaVersion != null) info.setJavaVersion(javaVersion.getContent()); XMLElement uninstallInfo = root.getFirstChildNamed ("uninstaller"); if (uninstallInfo != null) info.setWriteUninstaller( validateYesNoAttribute(uninstallInfo, "write", YES)); // We return the suitable Info object return info; }
3,240,949
protected ArrayList getLangpacksCodes(XMLElement data) throws CompilerException { // Initialisation ArrayList langpacks = new ArrayList(); XMLElement locals = requireChildNamed(data, "locale"); // We process each langpack markup Iterator iter = locals.getChildrenNamed("langpack").iterator(); while (iter.hasNext()) { XMLElement pack = (XMLElement) iter.next(); langpacks.add(requireAttribute(pack, "iso3")); } if (langpacks.isEmpty()) parseError (locals, "<locale> requires a <langpack>"); // We return the ArrayList return langpacks; }
protected ArrayList getLangpacksCodes(XMLElement data) throws CompilerException { // Initialisation ArrayList langpacks = new ArrayList(); XMLElement locals = requireChildNamed(data, "locale"); // We process each langpack markup Iterator iter = locals.getChildrenNamed("langpack").iterator(); while (iter.hasNext()) { XMLElement pack = (XMLElement) iter.next(); langpacks.add(requireAttribute(pack, "iso3")); } if (langpacks.isEmpty()) parseError (locals, "<locale> requires a <langpack>"); // We return the ArrayList return langpacks; }
3,240,950
protected ArrayList getLangpacksCodes(XMLElement data) throws CompilerException { // Initialisation ArrayList langpacks = new ArrayList(); XMLElement locals = requireChildNamed(data, "locale"); // We process each langpack markup Iterator iter = locals.getChildrenNamed("langpack").iterator(); while (iter.hasNext()) { XMLElement pack = (XMLElement) iter.next(); langpacks.add(requireAttribute(pack, "iso3")); } if (langpacks.isEmpty()) parseError (locals, "<locale> requires a <langpack>"); // We return the ArrayList return langpacks; }
protected ArrayList getLangpacksCodes(XMLElement data) throws CompilerException { // Initialisation ArrayList langpacks = new ArrayList(); XMLElement locals = requireChildNamed(data, "locale"); // We process each langpack markup Iterator iter = locals.getChildrenNamed("langpack").iterator(); while (iter.hasNext()) { XMLElement pack = (XMLElement) iter.next(); langpacks.add(requireAttribute(pack, "iso3")); } if (langpacks.isEmpty()) parseError(locals, "<locale> requires a <langpack>"); // We return the ArrayList return langpacks; }
3,240,951
protected ArrayList getNativeLibraries(XMLElement data) throws Exception { // Initialisation ArrayList natives = new ArrayList(); Vector v = data.getChildrenNamed("native"); // We add each native lib path to the list Iterator iter = v.iterator(); while (iter.hasNext()) { XMLElement el = (XMLElement) iter.next(); NativeLibrary nat = new NativeLibrary(); nat.path = IZPACK_HOME + "bin" + File.separator + "native" + File.separator + el.getAttribute("type") + File.separator + el.getAttribute("name"); nat.name = el.getAttribute("name"); natives.add(nat); } // We return the paths to the native libraries return natives; }
protected ArrayList getNativeLibraries(XMLElement data) throws Exception { // Initialisation ArrayList natives = new ArrayList(); Vector v = data.getChildrenNamed("native"); // We add each native lib path to the list Iterator iter = v.iterator(); while (iter.hasNext()) { XMLElement el = (XMLElement) iter.next(); NativeLibrary nat = new NativeLibrary(); nat.path = IZPACK_HOME + "bin" + File.separator + "native" + File.separator + el.getAttribute("type") + File.separator + el.getAttribute("name"); nat.name = el.getAttribute("name"); natives.add(nat); } // We return the paths to the native libraries return natives; }
3,240,952
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
protected int getOverrideValue(XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
3,240,953
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
3,240,954
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
3,240,955
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
3,240,956
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
protected int getOverrideValue (XMLElement f) { int override = PackSource.OVERRIDE_UPDATE; String override_val = f.getAttribute("override"); if (override_val != null) { if (override_val.equalsIgnoreCase("true")) { override = PackSource.OVERRIDE_TRUE; } else if (override_val.equalsIgnoreCase("false")) { override = PackSource.OVERRIDE_FALSE; } else if (override_val.equalsIgnoreCase("asktrue")) { override = PackSource.OVERRIDE_ASK_TRUE; } else if (override_val.equalsIgnoreCase("askfalse")) { override = PackSource.OVERRIDE_ASK_FALSE; } else if (override_val.equalsIgnoreCase("update")) { override = PackSource.OVERRIDE_UPDATE; } } return override; }
3,240,957
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
3,240,958
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
3,240,959
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
protected Packager getPackager() throws Exception { if (kind.equalsIgnoreCase(STANDARD)) return new StdPackager(output, packagerListener); else if (kind.equalsIgnoreCase(STANDARD_KUNSTSTOFF)) return new StdKunststoffPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB)) return new WebPackager(output, packagerListener); else if (kind.equalsIgnoreCase(WEB_KUNSTSTOFF)) return new WebKunststoffPackager(output, packagerListener); else throw new Exception("unknown installer kind"); }
3,240,960
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList(el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,961
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,962
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,963
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,964
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,965
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,966
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,967
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,968
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,969
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute(f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,970
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue(f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue(f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue(f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,971
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,972
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,973
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,974
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList(); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,975
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,976
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,977
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,978
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,979
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,980
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,981
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError (root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
protected ArrayList getPacks(XMLElement data) throws CompilerException { // Initialisation ArrayList packs = new ArrayList(); XMLElement root = requireChildNamed(data, "packs"); // dummy variable used for values from XML String val; // We process each pack markup int packCounter = 0; Iterator packIter = root.getChildrenNamed("pack").iterator(); while (packIter.hasNext()) { XMLElement el = (XMLElement) packIter.next(); // Trivial initialisations Pack pack = new Pack(); pack.number = packCounter++; pack.name = requireAttribute(el, "name"); pack.osConstraints = OsConstraint.getOsList (el); // TODO: unverified pack.required = requireYesNoAttribute(el, "required"); pack.description = requireChildNamed(el, "description").getContent(); pack.preselected = validateYesNoAttribute(el, "preselected", YES); // We get the parsables list Iterator iter = el.getChildrenNamed("parsable").iterator(); while (iter.hasNext()) { XMLElement p = (XMLElement) iter.next(); String targetFile = requireAttribute(p, "targetfile"); List osList = OsConstraint.getOsList (p); // TODO: unverified pack.parsables.add (new ParsableFile(targetFile, p.getAttribute("type", "plain"), p.getAttribute("encoding", null), osList)); } // We get the executables list iter = el.getChildrenNamed("executable").iterator(); while (iter.hasNext()) { XMLElement e = (XMLElement) iter.next(); // when to execute this executable int executeOn = ExecutableFile.NEVER; val = e.getAttribute("stage", "never"); if ("postinstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.POSTINSTALL; else if ("uninstall".equalsIgnoreCase(val)) executeOn = ExecutableFile.UNINSTALL; // main class of this executable String executeClass = e.getAttribute("class"); // type of this executable int executeType = ExecutableFile.BIN; val = e.getAttribute("type", "bin"); if ("jar".equalsIgnoreCase(val)) executeType = ExecutableFile.JAR; // what to do if execution fails int onFailure = ExecutableFile.ASK; val = e.getAttribute("failure", "ask"); if ("abort".equalsIgnoreCase(val)) onFailure = ExecutableFile.ABORT; else if ("warn".equalsIgnoreCase(val)) onFailure = ExecutableFile.WARN; // whether to keep the executable after executing it boolean keepFile = false; val = e.getAttribute ("keep"); if ("true".equalsIgnoreCase(val)) keepFile = true; // get arguments for this executable ArrayList argList = new ArrayList(); XMLElement args = e.getFirstChildNamed("args"); if (null != args) { argList = new ArrayList(); Iterator argIterator = args.getChildrenNamed("arg").iterator(); while (argIterator.hasNext()) { XMLElement arg = (XMLElement) argIterator.next(); argList.add(requireAttribute(arg, "value")); } } List osList = OsConstraint.getOsList(e); // TODO: unverified String targetfile_attr = requireAttribute(e, "targetfile"); pack.executables.add(new ExecutableFile(targetfile_attr, executeType, executeClass, executeOn, onFailure, argList, osList, keepFile)); } // We get the files list iter = el.getChildrenNamed("file").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute(f, "src"); String path; if (new File(src_attr).isAbsolute()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String targetdir_attr = requireAttribute (f, "targetdir"); try { addFile(file, targetdir_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the singlefiles list iter = el.getChildrenNamed("singlefile").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String src_attr = requireAttribute (f, "src"); String path; if (new File (src_attr).isAbsolute ()) path = src_attr; else path = basedir + File.separator + src_attr; File file = new File(path); int override = getOverrideValue (f); List osList = OsConstraint.getOsList (f); // TODO: unverified String target_attr = requireAttribute (f, "target"); try { addSingleFile(file, target_attr, osList, override, pack.packFiles); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // We get the fileset list iter = el.getChildrenNamed("fileset").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String dir_attr = requireAttribute (f, "dir"); String path; if (new File(dir_attr).isAbsolute()) path = dir_attr; else path = basedir + File.separator + dir_attr; boolean casesensitive = validateYesNoAttribute(f, "casesensitive", YES); // get includes and excludes Vector xcludesList = f.getChildrenNamed("include"); String[] includes = null; XMLElement xclude = null; if (xcludesList.size() > 0) { includes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); includes[j] = requireAttribute(xclude, "name"); } } xcludesList = f.getChildrenNamed("exclude"); String[] excludes = null; xclude = null; if (xcludesList.size() > 0) { excludes = new String[xcludesList.size()]; for (int j = 0; j < xcludesList.size(); j++) { xclude = (XMLElement) xcludesList.get(j); excludes[j] = requireAttribute(xclude, "name"); } } int override = getOverrideValue (f); String targetdir_attr = requireAttribute(f, "targetdir"); List osList = OsConstraint.getOsList (f); // TODO: unverified try { addFileSet(path, includes, excludes, targetdir_attr, osList, pack.packFiles, casesensitive, override); } catch (CompilerException x) { parseError(f, x.getMessage(), x); } } // get the updatechecks list // We get the fileset list iter = el.getChildrenNamed("updatecheck").iterator(); while (iter.hasNext()) { XMLElement f = (XMLElement) iter.next(); String casesensitive = f.getAttribute("casesensitive"); // get includes and excludes ArrayList includesList = new ArrayList (); Vector includesElementList = f.getChildrenNamed("include"); if (includesElementList != null) { for (Iterator include_it = includesElementList.iterator(); include_it.hasNext();) { XMLElement inc_el = (XMLElement)include_it.next(); String name = inc_el.getAttribute("name"); if (name != null) { includesList.add (name); } else { parseError(inc_el, "missing \"name\" attribute for <include> in <updatecheck>"); } } } ArrayList excludesList = new ArrayList (); Vector excludesElementList = f.getChildrenNamed("exclude"); if (excludesElementList != null) { for (Iterator exclude_it = excludesElementList.iterator(); exclude_it.hasNext();) { XMLElement excl_el = (XMLElement)exclude_it.next(); String name = excl_el.getAttribute("name"); if (name != null) { excludesList.add (name); } else { parseError(excl_el, "missing \"name\" attribute for <exclude> in <updatecheck>"); } } } pack.updatechecks.add (new UpdateCheck (includesList, excludesList, casesensitive)); } // We add the pack packs.add(pack); } if (packs.isEmpty()) parseError(root, "<packs> requires a <pack>"); // We return the ArrayList return packs; }
3,240,982
protected ArrayList getPanels(XMLElement data) throws CompilerException { // Initialisation ArrayList panels = new ArrayList(); XMLElement root = requireChildNamed(data, "panels"); // We process each langpack markup Iterator iter = root.getChildrenNamed("panel").iterator(); while (iter.hasNext()) { XMLElement xmlPanel = (XMLElement) iter.next(); List osList = OsConstraint.getOsList (xmlPanel); Panel panel = new Panel(); panel.osConstraints = osList; panel.className = xmlPanel.getAttribute("classname"); panels.add(panel); } if (panels.isEmpty()) parseError (root, "<panels> requires a <panel>"); // We return the ArrayList return panels; }
protected ArrayList getPanels(XMLElement data) throws CompilerException { // Initialisation ArrayList panels = new ArrayList(); XMLElement root = requireChildNamed(data, "panels"); // We process each langpack markup Iterator iter = root.getChildrenNamed("panel").iterator(); while (iter.hasNext()) { XMLElement xmlPanel = (XMLElement) iter.next(); List osList = OsConstraint.getOsList (xmlPanel); Panel panel = new Panel(); panel.osConstraints = osList; panel.className = xmlPanel.getAttribute("classname"); panels.add(panel); } if (panels.isEmpty()) parseError (root, "<panels> requires a <panel>"); // We return the ArrayList return panels; }
3,240,983
protected ArrayList getPanels(XMLElement data) throws CompilerException { // Initialisation ArrayList panels = new ArrayList(); XMLElement root = requireChildNamed(data, "panels"); // We process each langpack markup Iterator iter = root.getChildrenNamed("panel").iterator(); while (iter.hasNext()) { XMLElement xmlPanel = (XMLElement) iter.next(); List osList = OsConstraint.getOsList (xmlPanel); Panel panel = new Panel(); panel.osConstraints = osList; panel.className = xmlPanel.getAttribute("classname"); panels.add(panel); } if (panels.isEmpty()) parseError (root, "<panels> requires a <panel>"); // We return the ArrayList return panels; }
protected ArrayList getPanels(XMLElement data) throws CompilerException { // Initialisation ArrayList panels = new ArrayList(); XMLElement root = requireChildNamed(data, "panels"); // We process each langpack markup Iterator iter = root.getChildrenNamed("panel").iterator(); while (iter.hasNext()) { XMLElement xmlPanel = (XMLElement) iter.next(); List osList = OsConstraint.getOsList (xmlPanel); Panel panel = new Panel(); panel.osConstraints = osList; panel.className = xmlPanel.getAttribute("classname"); panels.add(panel); } if (panels.isEmpty()) parseError(root, "<panels> requires a <panel>"); // We return the ArrayList return panels; }
3,240,984
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,985
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (!src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,986
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,987
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError(root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,988
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,989
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,990
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,991
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException( "The uninstaller (" + uninst + ") seems to be missing: " + x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,992
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
protected ArrayList getResources(XMLElement data) throws CompilerException { // Initialisation ArrayList resources = new ArrayList(); XMLElement root = data.getFirstChildNamed("resources"); if (root == null) return resources; // We process each res markup Iterator iter = root.getChildrenNamed("res").iterator(); while (iter.hasNext()) { XMLElement res = (XMLElement) iter.next(); // Do not prepend basedir if src is already an absolute path File src = new File(requireAttribute(res, "src")); if (! src.isAbsolute()) src = new File(basedir, src.getPath()); resources.add(new Resource(requireAttribute(res, "id"), src.getPath(), validateYesNoAttribute(res, "parse", NO), res.getAttribute("type"), res.getAttribute("encoding"))); } if (resources.isEmpty()) parseError (root, "<resources> requires a <res>"); // Uninstaller must be added as a resource for standalone compiler InputStream uninst_is = getClass().getResourceAsStream("/lib/uninstaller.jar"); if (uninst_is == null) { String uninst = Compiler.IZPACK_HOME + "lib" + File.separator + "uninstaller.jar"; try { uninst_is = new FileInputStream (uninst); } catch (IOException x) { // it's a runtime exception if this can't be found throw new RuntimeException ("The uninstaller ("+uninst+") seems to be missing: "+x.toString()); } } resources.add(new Resource("IzPack.uninstaller", uninst_is)); // We return the ArrayList return resources; }
3,240,993
protected Properties getVariables(XMLElement data) throws Exception { this.varMap = new VariableValueMapImpl (); Properties retVal = null; // We get the varible list XMLElement root = data.getFirstChildNamed("variables"); if (root == null) return retVal; retVal = new Properties(); Iterator iter = root.getChildrenNamed("variable").iterator(); while (iter.hasNext()) { XMLElement var = (XMLElement) iter.next(); retVal.setProperty(requireAttribute(var, "name"), requireAttribute(var, "value")); varMap.setVariable(requireAttribute(var, "name"), requireAttribute(var, "value")); } return retVal; }
protected Properties getVariables(XMLElement data) throws Exception { this.varMap = new VariableValueMapImpl(); Properties retVal = null; // We get the varible list XMLElement root = data.getFirstChildNamed("variables"); if (root == null) return retVal; retVal = new Properties(); Iterator iter = root.getChildrenNamed("variable").iterator(); while (iter.hasNext()) { XMLElement var = (XMLElement) iter.next(); retVal.setProperty(requireAttribute(var, "name"), requireAttribute(var, "value")); varMap.setVariable(requireAttribute(var, "name"), requireAttribute(var, "value")); } return retVal; }
3,240,994
protected Properties getVariables(XMLElement data) throws Exception { this.varMap = new VariableValueMapImpl (); Properties retVal = null; // We get the varible list XMLElement root = data.getFirstChildNamed("variables"); if (root == null) return retVal; retVal = new Properties(); Iterator iter = root.getChildrenNamed("variable").iterator(); while (iter.hasNext()) { XMLElement var = (XMLElement) iter.next(); retVal.setProperty(requireAttribute(var, "name"), requireAttribute(var, "value")); varMap.setVariable(requireAttribute(var, "name"), requireAttribute(var, "value")); } return retVal; }
protected Properties getVariables(XMLElement data) throws Exception { this.varMap = new VariableValueMapImpl (); Properties retVal = null; // We get the varible list XMLElement root = data.getFirstChildNamed("variables"); if (root == null) return retVal; retVal = new Properties(); Iterator iter = root.getChildrenNamed("variable").iterator(); while (iter.hasNext()) { XMLElement var = (XMLElement) iter.next(); retVal.setProperty(requireAttribute(var, "name"), requireAttribute(var, "value")); varMap.setVariable(requireAttribute(var, "name"), requireAttribute(var, "value")); } return retVal; }
3,240,995
protected XMLElement getXMLTree() throws CompilerException, IOException { // Initialises the parser StdXMLParser parser = new StdXMLParser(); parser.setBuilder(new StdXMLBuilder()); parser.setReader(new StdXMLReader(new FileInputStream(filename))); parser.setValidator(new NonValidator()); // We get it XMLElement data = null; try { data = (XMLElement) parser.parse(); } catch (Exception x) { throw new CompilerException("Error parsing installation file", x); } // We check it if (!"installation".equalsIgnoreCase(data.getName())) parseError(data, "this is not an IzPack XML installation file"); if (!requireAttribute(data, "version").equalsIgnoreCase(VERSION)) parseError(data, "the file version is different from the compiler version"); // We finally return the tree return data; }
protected XMLElement getXMLTree() throws CompilerException, IOException { // Initialises the parser StdXMLParser parser = new StdXMLParser(); parser.setBuilder(new StdXMLBuilder()); parser.setReader(new StdXMLReader(new FileInputStream(filename))); parser.setValidator(new NonValidator()); // We get it XMLElement data = null; try { data = (XMLElement) parser.parse(); } catch (Exception x) { throw new CompilerException("Error parsing installation file", x); } // We check it if (!"installation".equalsIgnoreCase(data.getName())) parseError(data, "this is not an IzPack XML installation file"); if (!requireAttribute(data, "version").equalsIgnoreCase(VERSION)) parseError(data, "the file version is different from the compiler version"); // We finally return the tree return data; }
3,240,996
protected XMLElement getXMLTree() throws CompilerException, IOException { // Initialises the parser StdXMLParser parser = new StdXMLParser(); parser.setBuilder(new StdXMLBuilder()); parser.setReader(new StdXMLReader(new FileInputStream(filename))); parser.setValidator(new NonValidator()); // We get it XMLElement data = null; try { data = (XMLElement) parser.parse(); } catch (Exception x) { throw new CompilerException("Error parsing installation file", x); } // We check it if (!"installation".equalsIgnoreCase(data.getName())) parseError(data, "this is not an IzPack XML installation file"); if (!requireAttribute(data, "version").equalsIgnoreCase(VERSION)) parseError(data, "the file version is different from the compiler version"); // We finally return the tree return data; }
protected XMLElement getXMLTree() throws CompilerException, IOException { // Initialises the parser StdXMLParser parser = new StdXMLParser(); parser.setBuilder(new StdXMLBuilder()); parser.setReader(new StdXMLReader(new FileInputStream(filename))); parser.setValidator(new NonValidator()); // We get it XMLElement data = null; try { data = (XMLElement) parser.parse(); } catch (Exception x) { throw new CompilerException("Error parsing installation file", x); } // We check it if (!"installation".equalsIgnoreCase(data.getName())) parseError(data, "this is not an IzPack XML installation file"); if (!requireAttribute(data, "version").equalsIgnoreCase(VERSION)) parseError( data, "the file version is different from the compiler version"); // We finally return the tree return data; }
3,240,997
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,240,998
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,240,999
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,000
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,001
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println( " -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,002
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,003
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,004
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,005
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,006
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
public static void main(String[] args) { // Outputs some informations System.out.println(""); System.out.println(".:: IzPack - Version " + IZPACK_VERSION + " ::."); System.out.println(""); System.out.println("< compiler specifications version : " + VERSION + " >"); System.out.println(""); System.out.println("- Copyright (C) 2001-2003 Julien Ponge"); System.out.println("- Visit http://www.izforge.com/ for the latests releases"); System.out.println("- Released under the terms of the GNU GPL either version 2"); System.out.println(" of the licence, or any later version."); System.out.println(""); // exit code 1 means: error int exitCode = 1; // We analyse the command line parameters try { // Our arguments String filename; String base = "."; String kind = "standard"; String output; // First check int nArgs = args.length; if (nArgs < 3) throw new Exception("no arguments given"); // We get the IzPack home directory int stdArgsIndex; if (args[0].equalsIgnoreCase("-HOME")) { stdArgsIndex = 2; IZPACK_HOME = args[1]; } else stdArgsIndex = 0; if (!IZPACK_HOME.endsWith(File.separator)) IZPACK_HOME = IZPACK_HOME + File.separator; // The users wants to know the command line parameters if (args[stdArgsIndex].equalsIgnoreCase("-?")) { System.out.println("-> Command line parameters are : (xml file) [args]"); System.out.println(" (xml file): the xml file describing the installation"); System.out.println(" -b (base) : indicates the base path that the compiler will use for filenames"); System.out.println(" default is the current path"); System.out.println(" -k (kind) : indicates the kind of installer to generate"); System.out.println(" default is standard"); System.out.println(" -o (out) : indicates the output file name"); System.out.println(" default is the xml file name\n"); System.out.println(" When using vm option -DSTACKTRACE=true there is all kind of debug info "); System.out.println(""); } else {// We can parse the other parameters & try to compile the installation // We get the input file name and we initialize the output file name filename = args[stdArgsIndex]; output = filename.substring(0, filename.length() - 3) + "jar"; // We parse the other ones int pos = stdArgsIndex + 1; while (pos < nArgs) if ((args[pos].startsWith("-")) && (args[pos].length() == 2)) { switch (args[pos].toLowerCase().charAt(1)) { case 'b': if ((pos + 1) < nArgs) { pos++; base = args[pos]; } else throw new Exception("base argument missing"); break; case 'k': if ((pos + 1) < nArgs) { pos++; kind = args[pos]; } else throw new Exception("kind argument missing"); break; case 'o': if ((pos + 1) < nArgs) { pos++; output = args[pos]; } else throw new Exception("output argument missing"); break; default: throw new Exception("unknown argument"); } pos++; } else throw new Exception("bad argument"); // Outputs what we are going to do System.out.println("-> Processing : " + filename); System.out.println("-> Output : " + output); System.out.println("-> Base path : " + base); System.out.println("-> Kind : " + kind); System.out.println(""); // Calls the compiler Compiler compiler = new Compiler(filename, base, kind, output); CmdlinePackagerListener listener = new CmdlinePackagerListener(); compiler.setPackagerListener(listener); compiler.compile(); // Waits while (compiler.isAlive()) Thread.sleep(100); if (compiler.wasSuccessful()) exitCode = 0; System.out.println("Build time: "+new Date()); } } catch (Exception err) { // Something bad has happened System.err.println("-> Fatal error :"); System.err.println(" " + err.getMessage()); err.printStackTrace(); System.err.println(""); System.err.println("(tip : use -? to get the commmand line parameters)"); } // Closes the JVM System.exit(exitCode); }
3,241,007