1 package org.antmod.util; 2 3 import java.util.Enumeration ; 4 import java.util.Properties ; 5 import java.util.Vector ; 6 import java.util.logging.Logger ; 7 8 import org.apache.tools.ant.taskdefs.Execute; 9 10 15 public final class Os { 16 private final static Logger LOGGER = Logger.getLogger(Os.class.getName()); 17 18 private final static Properties ENV_VARS = new Properties (); 19 static { 20 loadEnvironment(ENV_VARS); 21 } 22 23 24 private Os() { 25 } 26 27 32 public static String getEnvironmentVariable(String varName) { 33 return ENV_VARS.getProperty(varName); 34 } 35 36 37 40 private static void loadEnvironment(Properties environmentVariables) { 41 Vector osEnv = Execute.getProcEnvironment(); 42 for (Enumeration e = osEnv.elements(); e.hasMoreElements();) { 43 String entry = (String ) e.nextElement(); 44 int pos = entry.indexOf('='); 45 if (pos == -1) { 46 LOGGER.warning("Ignoring: " + entry); 47 } else { 48 environmentVariables.put(entry.substring(0, pos), entry.substring(pos + 1)); 49 } 50 } 51 } 52 } 53 | Popular Tags |