Methods Summary |
---|
public static java.lang.String | getApplicationEntryPoint()
return( APPLICATION_ENTRY_POINT );
|
public static java.lang.String | getApplicationIdentifier()
return( APPLICATION_ID );
|
public static java.lang.String | getApplicationName()
return( APPLICATION_NAME );
|
public static java.lang.String | getApplicationPath()Returns the full path to the directory where Azureus is installed
and running from.
if ( app_path != null ){
return( app_path );
}
String temp_app_path = System.getProperty("azureus.install.path", System.getProperty("user.dir"));
if ( !temp_app_path.endsWith(SEP)){
temp_app_path += SEP;
}
app_path = temp_app_path;
return( app_path );
|
public static java.lang.String | getAzureusJarPath()
String str = getApplicationPath();
if( Constants.isOSX ){
str += SystemProperties.getApplicationName() + ".app/Contents/Resources/Java/";
}
return( str + "Azureus2.jar" );
|
public static java.lang.String | getDocPath()
PlatformManager platformManager = PlatformManagerFactory.getPlatformManager();
File fDocPath = null;
try {
fDocPath = platformManager.getLocation(PlatformManager.LOC_DOCUMENTS);
} catch (PlatformManagerException e) {
}
if (fDocPath == null) {
// should never happen.. but if we are missing a dll..
fDocPath = new File(getUserPath(), "Documents");
}
return fDocPath.getAbsolutePath();
|
public static java.lang.String | getEnvironmentalVariable(java.lang.String _var)Will attempt to retrieve an OS-specific environmental var.
Process p = null;
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
BufferedReader br = null;
// this approach doesn't work at all on Windows 95/98/ME - it just hangs
// so get the hell outta here!
if ( Constants.isWindows9598ME ){
return( "" );
}
try {
if ( Constants.isWindows ) {
p = r.exec( "cmd.exe /c set" );
}
else { //we assume unix
p = r.exec( "env" );
}
String system_encoding = LocaleUtil.getSingleton().getSystemEncoding();
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"SystemProperties::getEnvironmentalVariable - " + _var
+ ", system encoding = " + system_encoding));
br = new BufferedReader( new InputStreamReader( p.getInputStream(), system_encoding), 8192);
String line;
while( (line = br.readLine()) != null ) {
int idx = line.indexOf( '=" );
if (idx >= 0) {
String key = line.substring( 0, idx );
String value = line.substring( idx+1 );
envVars.setProperty( key, value );
}
}
br.close();
}
catch (Throwable t) {
if (br != null) try { br.close(); } catch (Exception ingore) {}
}
return envVars.getProperty( _var, "" );
|
public static java.lang.String | getUserPath()Returns the full path to the user's home azureus directory.
Under unix, this is usually ~/.azureus/
Under Windows, this is usually .../Documents and Settings/username/Application Data/Azureus/
Under OSX, this is usually /Users/username/Library/Application Support/Azureus/
if (user_path != null) {
return user_path;
}
// WATCH OUT!!!! possible recursion here if logging is changed so that it messes with
// config initialisation - that's why we don't assign the user_path variable until it
// is complete - an earlier bug resulted in us half-assigning it and using it due to
// recursion. At least with this approach we'll get (worst case) stack overflow if
// a similar change is made, and we'll spot it!!!!
// Super Override -- no AZ_DIR or xxx_DEFAULT added at all.
String temp_user_path = System.getProperty(SYS_PROP_CONFIG_OVERRIDE);
try {
if (temp_user_path != null) {
if (!temp_user_path.endsWith(SEP)) {
temp_user_path += SEP;
}
File dir = new File(temp_user_path);
if (!dir.exists()) {
FileUtil.mkdirs(dir);
}
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"SystemProperties::getUserPath(Custom): user_path = "
+ temp_user_path));
return temp_user_path;
}
// No override, get it from platform manager
PlatformManager platformManager = PlatformManagerFactory.getPlatformManager();
try {
temp_user_path = platformManager.getLocation(
PlatformManager.LOC_USER_DATA).getPath() + SEP;
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID,
"SystemProperties::getUserPath: user_path = " + temp_user_path));
}
} catch (Exception e) {
if (Logger.isEnabled()) {
Logger.log(new LogEvent(LOGID,
"Unable to retrieve user config path from "
+ platformManager.getClass().getName()
+ "Make sure aereg.dll is present."));
}
}
// If platform failed, try some hackery
if (temp_user_path == null) {
String userhome = System.getProperty("user.home");
if (Constants.isWindows) {
temp_user_path = getEnvironmentalVariable("APPDATA");
if (temp_user_path != null && temp_user_path.length() > 0) {
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"Using user config path from APPDATA env var instead: "
+ temp_user_path));
} else {
temp_user_path = userhome + SEP + WIN_DEFAULT;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"Using user config path from java user.home var instead: "
+ temp_user_path));
}
temp_user_path = temp_user_path + SEP + APPLICATION_NAME + SEP;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"SystemProperties::getUserPath(Win): user_path = "
+ temp_user_path));
} else if (Constants.isOSX) {
temp_user_path = userhome + SEP + OSX_DEFAULT + SEP
+ APPLICATION_NAME + SEP;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"SystemProperties::getUserPath(Mac): user_path = "
+ temp_user_path));
} else {
// unix type
temp_user_path = userhome + SEP + "."
+ APPLICATION_NAME.toLowerCase() + SEP;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID,
"SystemProperties::getUserPath(Unix): user_path = "
+ temp_user_path));
}
}
//if the directory doesn't already exist, create it
File dir = new File(temp_user_path);
if (!dir.exists()) {
FileUtil.mkdirs(dir);
}
return temp_user_path;
} finally {
user_path = temp_user_path;
}
|
public static boolean | isJavaWebStartInstance()Returns whether or not this running instance was started via
Java's Web Start system.
try {
String java_ws_prop = System.getProperty("azureus.javaws");
return ( java_ws_prop != null && java_ws_prop.equals( "true" ) );
}
catch (Throwable e) {
//we can get here if running in an applet, as we have no access to system props
return false;
}
|
public static void | setApplicationEntryPoint(java.lang.String entry_point)
if ( entry_point != null && entry_point.trim().length() > 0 ){
APPLICATION_ENTRY_POINT = entry_point.trim();
}
|
public static void | setApplicationIdentifier(java.lang.String application_id)
if ( application_id != null && application_id.trim().length() > 0 ){
APPLICATION_ID = application_id.trim();
}
|
public static void | setApplicationName(java.lang.String name)
if ( name != null && name.trim().length() > 0 ){
name = name.trim();
if ( user_path != null ){
if ( !name.equals( APPLICATION_NAME )){
System.out.println( "**** SystemProperties::setApplicationName called too late! ****" );
}
}
APPLICATION_NAME = name;
}
|