import java.io.*;
import java.util.*;
import com.perforce.api.*;
/**
* Convenience class for the examples. This is where the environment gets set
* up for all the examples. It's extracted here in an attempt to clarify
* the examples.
*/
public class Common {
private static Env env;
private static Properties prps;
public final static Env setup() {
prps = new Properties(System.getProperties());
try {
// First, try loading from the properties file.
prps.load(new BufferedInputStream(new FileInputStream("p4.properties")));
System.setProperties(prps);
env = new Env(prps);
} catch (IOException ioex) {
Debug.error("Could not load properties.");
/* If the properties file failed, we could set the environment manually.
* Another option would be to simply fail at this point.
*/
System.exit(-1);
env = new Env();
/*
env.setPort("public.perforce.com:1666");
env.setUser("david_markley");
env.setClient("david_markley-pc");
env.setPassword("mylittlesecret");
env.setSystemDrive("D");
env.setSystemRoot("D:\\WINNT");
env.setExecutable("D:\\Program Files\\Perforce\\P4.EXE");
*/
}
/* Uncomment these lines to turn on stdout debugging info. */
Debug.setDebugLevel(Debug.VERBOSE);
Debug.setLogLevel(Debug.LOG_SPLIT);
return env;
}
public Properties getProperties() {
return prps;
}
public Env getEnv() {
return env;
}
}