From: <ls...@us...> - 2011-06-21 15:56:41
|
Revision: 5821 http://jnode.svn.sourceforge.net/jnode/?rev=5821&view=rev Author: lsantha Date: 2011-06-21 15:56:32 +0000 (Tue, 21 Jun 2011) Log Message: ----------- Removing unused Java code. Removed Paths: ------------- classlib6/builder/src/builder/org/jnode/ant/taskdefs/Asm.java classlib6/builder/src/builder/org/jnode/ant/taskdefs/TemplateTask.java classlib6/builder/src/builder/org/jnode/build/AsmSourceInfo.java classlib6/builder/src/builder/org/jnode/build/JNodeClassNotFoundException.java classlib6/builder/src/builder/org/jnode/build/VMwareBuilderTask.java Deleted: classlib6/builder/src/builder/org/jnode/ant/taskdefs/Asm.java =================================================================== --- classlib6/builder/src/builder/org/jnode/ant/taskdefs/Asm.java 2011-06-21 15:36:21 UTC (rev 5820) +++ classlib6/builder/src/builder/org/jnode/ant/taskdefs/Asm.java 2011-06-21 15:56:32 UTC (rev 5821) @@ -1,433 +0,0 @@ -/* - * $Id: Asm.java 5071 2009-02-28 16:38:38Z fduminy $ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.ant.taskdefs; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Execute; -import org.apache.tools.ant.taskdefs.MatchingTask; -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - * Description of the Class. - * - * @author epr - * @version $Revision: 5071 $ - */ -public class Asm extends MatchingTask { - - public static class IncludeDir { - private File dir; - - /** - * Constructor for IncludeDir. - */ - public IncludeDir() { - super(); - } - - /** - * Returns the dir. - * - * @return File - */ - public File getDir() { - return dir; - } - - /** - * Sets the dir. - * - * @param dir The dir to set - */ - public void setDir(File dir) { - this.dir = dir; - } - } - - private static String postFixSlash(String s) { - if (!s.endsWith(File.separator)) { - return s + File.separator; - } else { - return s; - } - } - - private int bits = 32; - - private File destdir; - - private String ext = "o"; - - private Set<IncludeDir> includeDirs = new HashSet<IncludeDir>(); - - private File listFile; - - private String outputFormat; - - private File srcdir; - - private boolean enableJNasm; - - private String version; - - /** - * Add an includedir. - * - * @param dir - */ - public void addConfiguredIncludeDir(IncludeDir dir) { - includeDirs.add(dir); - } - - /** - * Description of the Method. - * - * @param srcFile - * @param dstFile - * @throws BuildException Description of Exception - * @throws IOException Description of the Exception - */ - private void doNasm(File srcFile, File dstFile) throws BuildException, - IOException { - - Execute exec = new Execute(); - ArrayList<String> cmdLine = new ArrayList<String>(); - if (bits == 64) { - cmdLine.add("yasm"); - } else if (Os.isFamily("windows")) { - cmdLine.add("nasmw.exe"); - } else { - cmdLine.add("nasm"); - } - - cmdLine.add("-o"); - cmdLine.add(dstFile.toString()); - - if (bits == 64) { - cmdLine.add("-m"); - cmdLine.add("amd64"); - // Set preprocessor - cmdLine.add("-r"); - cmdLine.add("nasm"); - } - - cmdLine.add("-D"); - cmdLine.add("BITS" + bits); - - if (version != null) { - cmdLine.add("-D"); - cmdLine.add("JNODE_VERSION='" + version + "'"); - } - - if (outputFormat != null) { - cmdLine.add("-f"); - cmdLine.add(outputFormat); - } - - if (listFile != null) { - cmdLine.add("-l"); - cmdLine.add(listFile.toString()); - } - - for (IncludeDir dir : includeDirs) { - cmdLine.add("-I"); - cmdLine.add(postFixSlash(dir.getDir().toString())); - } - - cmdLine.add(srcFile.toString()); - - log("cmdLine=" + cmdLine, Project.MSG_VERBOSE); - - exec.setCommandline(cmdLine.toArray(new String[cmdLine - .size()])); - - dstFile.getParentFile().mkdirs(); - int rc = exec.execute(); - - if (rc != 0) { - destdir.delete(); - throw new BuildException("Asm failed on " - + srcFile.getAbsolutePath()); - } - } - - /** - * Description of the Method. - * - * @throws BuildException Description of Exception - */ - public void execute() throws BuildException { - - if (srcdir == null) { - throw new BuildException("Error: srcdir attribute must be set!", - getLocation()); - } else if (!srcdir.isDirectory()) { - throw new BuildException("Error: srcdir directory is not valid!", - getLocation()); - } - - if (destdir == null) { - throw new BuildException("Error: destdir attribute must be set!", - getLocation()); - } else if (!destdir.isDirectory()) { - throw new BuildException("Error: destdir directory is not valid!", - getLocation()); - } - - try { - if (!enableJNasm) { - executeAsm(); - } - } catch (IOException ex) { - throw new BuildException(ex); - } - } - - /** - * Description of the Method. - * - * @throws BuildException Description of Exception - * @throws IOException Description of the Exception - */ - protected void executeAsm() throws BuildException, IOException { - - DirectoryScanner scanner = getDirectoryScanner(getSrcdir()); - String allFiles[] = scanner.getIncludedFiles(); - Map<File, File> compileMap = new HashMap<File, File>(); - scanDir(srcdir, destdir, allFiles, compileMap); - - if (compileMap.size() > 0) { - log("Compiling " + compileMap.size() + " source files to " - + destdir); - - for (File srcFile : compileMap.keySet()) { - File dstFile = compileMap.get(srcFile); - doNasm(srcFile, dstFile); - } - } - } - - /** - * Gets the number of bits of the target platform. - * - * @return 32/64 - */ - public final int getBits() { - return this.bits; - } - - /** - * Returns the destdir. - * - * @return File - */ - public File getDestdir() { - return destdir; - } - - /** - * Returns the ext. - * - * @return String - */ - public String getExtension() { - return ext; - } - - /** - * Returns the listFile. - * - * @return File - */ - public File getListFile() { - return listFile; - } - - /** - * Returns the outputFormat. - * - * @return String - */ - public String getOutputFormat() { - return outputFormat; - } - - /** - * Returns the srcdir. - * - * @return File - */ - public File getSrcdir() { - return srcdir; - } - - /** - * Scans the directory looking for source files to be compiled. The results - * are returned in the class variable compileList - * - * @param srcDir Description of Parameter - * @param destDir Description of Parameter - * @param files Description of Parameter - * @param compileMap - * @throws IOException Description of the Exception - */ - protected void scanDir(File srcDir, File destDir, String[] files, - Map<File, File> compileMap) throws IOException { - long now = System.currentTimeMillis(); - - for (int c = 0; c < files.length; c++) { - File aFile = new File(srcdir, files[c]); - - // get the path within the uriroot - String fileDirString = aFile.getParentFile().toString(); - String rootDirString = srcdir.toString(); - - int diff = fileDirString.compareTo(rootDirString); - String destSubDir = fileDirString.substring( - fileDirString.length() - diff, fileDirString.length()) - .replace('\\', '/'); - - // log(destSubDir); - File fileDir = new File(destDir.toString() + destSubDir); - - String objName = aFile.getName().substring(0, - aFile.getName().indexOf(".asm")) - + "." + ext; - File objFile = new File(fileDir, objName); - - // check if the file has been modified in the future, error? - if (aFile.lastModified() > now) { - log("Warning: file modified in the future: " + aFile.getName(), - Project.MSG_WARN); - } - - if (!objFile.exists() - || aFile.lastModified() > objFile.lastModified()) { - if (!objFile.exists()) { - log("Compiling " + aFile.getPath() + " because class file " - + objFile.getPath() + " does not exist", - Project.MSG_VERBOSE); - } else { - log("Compiling " + aFile.getPath() - + " because it is out of date with respect to " - + objFile.getPath(), Project.MSG_VERBOSE); - } - - compileMap.put(aFile, objFile); - log(aFile.toString(), Project.MSG_VERBOSE); - } - } - } - - /** - * Sets the number of bits of the target platform. - * - * @param bits 32/64 - */ - public final void setBits(int bits) { - if ((bits != 32) && (bits != 64)) { - throw new IllegalArgumentException("Invalid bits value " + bits); - } - this.bits = bits; - } - - /** - * Sets the Destdir attribute of the JspC object. - * - * @param destDir The new Destdir value - */ - public void setDestdir(File destDir) { - this.destdir = destDir; - } - - /** - * Sets the ext. - * - * @param ext The ext to set - */ - public void setExtension(String ext) { - this.ext = ext; - } - - /** - * Sets the listFile. - * - * @param listFile The listFile to set - */ - public void setListFile(File listFile) { - this.listFile = listFile; - } - - /** - * Sets the outputFormat. - * - * @param outputFormat The outputFormat to set - */ - public void setOutputFormat(String outputFormat) { - this.outputFormat = outputFormat; - } - - /** - * Sets the srcdir. - * - * @param srcdir The srcdir to set - */ - public void setSrcdir(File srcdir) { - this.srcdir = srcdir; - } - - /** - * @return Returns the enableJNasm. - */ - public final boolean isEnableJNasm() { - return enableJNasm; - } - - /** - * @param enableJNasm The enableJNasm to set. - */ - public final void setEnableJNasm(boolean enableJNasm) { - this.enableJNasm = enableJNasm; - } - - /** - * @return Returns the version. - */ - public final String getVersion() { - return version; - } - - /** - * @param version The version to set. - */ - public final void setVersion(String version) { - this.version = version; - } -} Deleted: classlib6/builder/src/builder/org/jnode/ant/taskdefs/TemplateTask.java =================================================================== --- classlib6/builder/src/builder/org/jnode/ant/taskdefs/TemplateTask.java 2011-06-21 15:36:21 UTC (rev 5820) +++ classlib6/builder/src/builder/org/jnode/ant/taskdefs/TemplateTask.java 2011-06-21 15:56:32 UTC (rev 5821) @@ -1,170 +0,0 @@ -/* - * $Id$ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.ant.taskdefs; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -/** - * @author Levente S\u00e1ntha - */ -public class TemplateTask extends Task { - private ArrayList<Token> tokens = new ArrayList<Token>(); - private String file; - private String toFile; - - @Override - public void execute() throws BuildException { - try { - //check file - if (file == null || file.trim().length() == 0) - return; - - File ff = new File(file); - if (!ff.exists()) - return; - - //check toFile - if (toFile == null || toFile.trim().length() == 0) - return; - - //check tokens - boolean found = true; - for (Token t : tokens) { - if (t.name == null || t.name.trim().length() == 0) { - t.name = null; - found = false; - } else if (t.value == null || - t.value.trim().length() == 0 || - t.value.startsWith("${") && t.value.endsWith("}")) { - t.value = null; - found = false; - } - } - - //read input file - FileReader fr = new FileReader(ff); - StringWriter sw = new StringWriter(); - char[] buff = new char[512]; - int cc; - while ((cc = fr.read(buff)) > 0) { - sw.write(buff, 0, cc); - } - fr.close(); - sw.close(); - - if (found) { - //default token - Token enabled = new Token(); - enabled.setName("ENABLED = false"); - enabled.setValue("ENABLED = true"); - tokens.add(enabled); - } - - //replace tokens - String s1 = sw.toString(); - if (found) { - for (Token t : tokens) { - s1 = s1.replace(t.name, t.value); - } - } - - String s2 = ""; - - //read output file - ff = new File(toFile); - if (ff.exists()) { - fr = new FileReader(ff); - sw = new StringWriter(); - buff = new char[512]; - while ((cc = fr.read(buff)) > 0) { - sw.write(buff, 0, cc); - } - fr.close(); - sw.close(); - s2 = sw.toString(); - } - - //if changed replace old file contents with new file contents - if (!s1.equals(s2)) { - ff.getAbsoluteFile().getParentFile().mkdirs(); - FileWriter fw = new FileWriter(ff); - fw.write(s1); - fw.close(); - } - } catch (Exception x) { - throw new BuildException(x); - } - } - - public String getFile() { - return file; - } - - public void setFile(String file) { - this.file = file; - } - - public String getToFile() { - return toFile; - } - - public void setToFile(String toFile) { - this.toFile = toFile; - } - - public Token createToken() { - Token token = new Token(); - tokens.add(token); - return token; - } - - public static class Token { - String name; - String value; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @Override - public String toString() { - return "Token(" + name + "," + value + ")"; - } - } -} Deleted: classlib6/builder/src/builder/org/jnode/build/AsmSourceInfo.java =================================================================== --- classlib6/builder/src/builder/org/jnode/build/AsmSourceInfo.java 2011-06-21 15:36:21 UTC (rev 5820) +++ classlib6/builder/src/builder/org/jnode/build/AsmSourceInfo.java 2011-06-21 15:56:32 UTC (rev 5821) @@ -1,87 +0,0 @@ -/* - * $Id: AsmSourceInfo.java 5071 2009-02-28 16:38:38Z fduminy $ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.build; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * This class contains information needed for the assembly compilation - * of the nano kernel sources. - * - * @author Ewout Prangsma (ep...@us...) - */ -public final class AsmSourceInfo { - - /** - * Include directories. - */ - private final List<File> includeDirs = new ArrayList<File>(); - - /** - * Main source file. - */ - private File sourceFile; - - /** - * Return a list of all configured include directories. - * - * @return - */ - public final List<File> includeDirs() { - return Collections.unmodifiableList(includeDirs); - } - - /** - * Gets the main source file. - * - * @return Returns the sourceFile. - */ - public final File getSrcFile() { - return sourceFile; - } - - /** - * Sets the main source file. - * - * @param sourceFile The sourceFile to set. - */ - public final void setSrcFile(File sourceFile) { - this.sourceFile = sourceFile; - } - - /** - * Create an includeDir sub element. - * - * @return - */ - public IncludeDir createIncludeDir() { - return new IncludeDir(); - } - - public final class IncludeDir { - public void setDir(File dir) { - includeDirs.add(dir); - } - } -} Deleted: classlib6/builder/src/builder/org/jnode/build/JNodeClassNotFoundException.java =================================================================== --- classlib6/builder/src/builder/org/jnode/build/JNodeClassNotFoundException.java 2011-06-21 15:36:21 UTC (rev 5820) +++ classlib6/builder/src/builder/org/jnode/build/JNodeClassNotFoundException.java 2011-06-21 15:56:32 UTC (rev 5821) @@ -1,32 +0,0 @@ -/* - * $Id: JNodeClassNotFoundException.java 4971 2009-02-02 06:44:38Z lsantha $ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.build; - - -final class JNodeClassNotFoundException extends Exception { - - /** - * @param s - */ - public JNodeClassNotFoundException(String s) { - super(s); - } -} Deleted: classlib6/builder/src/builder/org/jnode/build/VMwareBuilderTask.java =================================================================== --- classlib6/builder/src/builder/org/jnode/build/VMwareBuilderTask.java 2011-06-21 15:36:21 UTC (rev 5820) +++ classlib6/builder/src/builder/org/jnode/build/VMwareBuilderTask.java 2011-06-21 15:56:32 UTC (rev 5821) @@ -1,321 +0,0 @@ -/* - * $Id: VMwareBuilderTask.java 5080 2009-03-01 10:21:21Z fduminy $ - * - * Copyright (C) 2003-2009 JNode.org - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; If not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.jnode.build; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Properties; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -/** - * This task builds a VMWare '.vmx' file to allow JNode to be run using VMWare player. - * - * @author ... - * @author cr...@jn... - */ -public class VMwareBuilderTask extends Task { - - private String logFile; // log file use for kernel debugger messages - private String isoFile; - private int memSize; - private String overrideFile; - private String vmdkImageFile; - private String saveDir; - - /** - * @return Returns the memory size. - */ - public final int getMemSize() { - return memSize; - } - - /** - * @param memSize The memory size to set. - */ - public final void setMemSize(int memSize) { - this.memSize = memSize; - } - - /** - * @return Returns the log file. - */ - public final String getLogFile() { - return logFile; - } - - /** - * @param logFile The log file to set. - */ - public final void setLogFile(String logFile) { - this.logFile = logFile; - } - - /** - * The VmdkImage file is a VMX virtual disk image file. - * - * @return Returns the VmdkImage file or <code>null</code> - */ - public String getVmdkImageFile() { - return vmdkImageFile; - } - - /** - * @param vmdkImageFile The VmdkImage file to set. - */ - public void setVmdkImageFile(String vmdkImageFile) { - this.vmdkImageFile = vmdkImageFile; - } - - /** - * The override file is a Java Properties file containing VMX settings - * to override the default ones hard-wired into this class. - * - * @return Returns the override file or <code>null</code> - */ - public String getOverrideFile() { - return overrideFile; - } - - /** - * @param overrideFile The override file to set. - */ - public void setOverrideFile(String overrideFile) { - this.overrideFile = overrideFile; - } - - /** - * The save directory is used to preserve certain VMWare state - * files across 'clean' builds. - * - * @return the save directory - */ - public String getSaveDir() { - return saveDir; - } - - /** - * @param saveDir the save directory to set - */ - public void setSaveDir(String saveDir) { - this.saveDir = saveDir; - } - - /** - * @see org.apache.tools.ant.Task#execute() - */ - @Override - public void execute() throws BuildException { - // Build the default properties, based on the supplied memSize and logFile. - Properties props = new Properties(); - buildDefaultProperties(props); - - if (overrideFile != null && overrideFile.length() > 0) { - // If VMX overrides are provided, read them and add them to the properties; - BufferedReader br = null; - try { - // Unfortunately, we cannot use java.util.Property#load(...) because - // VMX properties can have ':' in the property name. - br = new BufferedReader(new FileReader(overrideFile)); - String line; - final Pattern propertyPattern = Pattern.compile("^([a-zA-Z0-9\\.:]+)\\s*=\\s*\"([^\"]*)\""); - final Pattern commentPattern = Pattern.compile("^#"); - while ((line = br.readLine()) != null) { - line = line.trim(); - if (line.isEmpty() || commentPattern.matcher(line).find()) { - continue; - } - Matcher matcher = propertyPattern.matcher(line); - if (!matcher.find()) { - throw new BuildException( - "Cannot parse this VMX override: '" + line + "'"); - } - props.put(matcher.group(1), matcher.group(2)); - } - } catch (FileNotFoundException ex) { - throw new BuildException( - "Cannot open the VMX override file: " + overrideFile, ex); - } catch (IOException ex) { - throw new BuildException( - "Problem reading the VMX override file: " + overrideFile, ex); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ex) { - /* ignore it */ - } - } - } - } - - if (vmdkImageFile != null && vmdkImageFile.length() > 0) { - File file = new File(vmdkImageFile); - if (!file.exists()) { - System.err.println(vmdkImageFile + " does not exists"); - } else if (file.length() == 0) { - System.err.println(vmdkImageFile + " is empty"); - } else { - // Add VMX properties to configure a virtual disk - props.setProperty("ide1:0.present", "TRUE"); - props.setProperty("ide1:0.fileName", vmdkImageFile); - props.setProperty("ide1:0.mode", "persistent"); - props.setProperty("ide1:0.startConnected", "TRUE"); - props.setProperty("ide1:0.writeThrough", "TRUE"); - props.setProperty("ide1:0.redo", ""); - } - } - - // Now output the VMX file from the properties, sorted in key order for neatness. - File vmxFile = new File(isoFile + ".vmx"); - try { - FileWriter out = new FileWriter(vmxFile); - try { - PrintWriter w = new PrintWriter(out); - TreeSet<Object> keys = new TreeSet<Object>(); - keys.addAll(props.keySet()); - for (Object key : keys) { - Object value = props.get(key); - w.println(key + " = \"" + value + "\""); - } - } finally { - out.close(); - } - } catch (IOException ex) { - throw new BuildException("Cannot write the VMX file: " + vmxFile); - } - - // Finally reinstate the saved JNode.nvram file if we have one. - if (saveDir != null) { - File savedNVRam = new File(saveDir, "JNode.nvram"); - File nvram = new File(new File(isoFile).getParentFile(), "JNode.nvram"); - if (savedNVRam.exists() && !nvram.exists()) { - InputStream is = null; - OutputStream os = null; - try { - is = new FileInputStream(savedNVRam); - os = new FileOutputStream(nvram); - byte[] buffer = new byte[(int) savedNVRam.length()]; - is.read(buffer); - os.write(buffer); - os.flush(); - } catch (IOException ex) { - throw new BuildException("Cannot copy the saved 'JNode.nvram' file: " + - ex.getMessage()); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException ex) { - // ignore - } - } - if (os != null) { - try { - os.close(); - } catch (IOException ex) { - // ignore - } - } - } - } - } - } - - private void buildDefaultProperties(Properties props) { - props.put("config.version", "8"); - props.put("virtualHW.version", "4"); - props.put("memsize", String.valueOf(memSize)); - props.put("MemAllowAutoScaleDown", "FALSE"); - - props.put("ide0:0.present", "TRUE"); - props.put("ide0:0.startConnected", "TRUE"); - props.put("ide0:0.fileName", new File(isoFile).getName()); - props.put("ide0:0.deviceType", "cdrom-image"); - props.put("ide0:0.redo", ""); - - props.put("ide1:0.present", "FALSE"); - props.put("ide1:0.startConnected", "TRUE"); - - props.put("floppy0.present", "FALSE"); - props.put("usb.present", "TRUE"); - props.put("sound.present", "FALSE"); - props.put("sound.virtualDev", "es1371"); - props.put("displayName", "JNode"); - props.put("guestOS", "dos"); - - props.put("nvram", "JNode.nvram"); - props.put("MemTrimRate", "-1"); - - final String osName = System.getProperty("os.name").toLowerCase(); - if (osName.contains("linux") || osName.contains("unix") || - osName.contains("bsd")) { - props.put("ethernet0.connectionType", "bridged"); - props.put("ethernet0.vnet", "/dev/vmnet1"); - } - props.put("ethernet0.addressType", "generated"); - props.put("ethernet0.generatedAddress", "00:0c:29:2a:96:30"); - props.put("ethernet0.generatedAddressOffset", "0"); - props.put("ethernet0.present", "TRUE"); - props.put("ethernet0.startConnected", "TRUE"); - - props.put("uuid.location", "56 4d 94 59 c9 96 80 88-6c 3a 37 80 04 68 c9 b2"); - props.put("uuid.bios", "56 4d 94 59 c9 96 80 88-6c 3a 37 80 04 68 c9 b2"); - - if (logFile != null && logFile.trim().length() != 0) { - props.put("serial0.present", "TRUE"); - props.put("serial0.fileType", "file"); - props.put("serial0.fileName", logFile); - } - - props.put("tools.syncTime", "TRUE"); - props.put("uuid.action", "create"); - props.put("checkpoint.vmState", ""); - } - - /** - * @return Returns the isoFile. - */ - public final String getIsoFile() { - return isoFile; - } - - /** - * @param isoFile The isoFile to set. - */ - public final void setIsoFile(String isoFile) { - this.isoFile = isoFile; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |