⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemproperties.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   SystemProperties.java

package org.gudy.azureus2.core3.util;

import java.io.*;
import java.util.Properties;
import org.gudy.azureus2.core3.internat.LocaleUtil;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.platform.PlatformManager;
import org.gudy.azureus2.platform.PlatformManagerFactory;

// Referenced classes of package org.gudy.azureus2.core3.util:
//			Constants, FileUtil

public class SystemProperties
{

	private static final LogIDs LOGID;
	public static final String SYS_PROP_CONFIG_OVERRIDE = "azureus.config.path";
	public static final String SEP = System.getProperty("file.separator");
	public static String APPLICATION_NAME = "Azureus";
	private static String APPLICATION_ID = "az";
	private static String APPLICATION_ENTRY_POINT = "org.gudy.azureus2.ui.swt.Main";
	private static final String WIN_DEFAULT = "Application Data";
	private static final String OSX_DEFAULT = (new StringBuilder()).append("Library").append(SEP).append("Application Support").toString();
	private static String user_path;
	private static String app_path;

	public SystemProperties()
	{
	}

	public static void determineApplicationName()
	{
		if (Constants.isOSX)
		{
			String classpath = System.getProperty("java.class.path");
			if (classpath == null)
			{
				System.out.println("SystemProperties: determineApplicationName - class path is null");
			} else
			{
				int dot_pos = classpath.indexOf(".app/Contents");
				if (dot_pos == -1)
				{
					System.out.println((new StringBuilder()).append("SystemProperties: determineApplicationName -  can't determine application name from ").append(classpath).toString());
				} else
				{
					int start_pos;
					for (start_pos = dot_pos; start_pos >= 0 && classpath.charAt(start_pos) != '/'; start_pos--);
					String app_name = classpath.substring(start_pos + 1, dot_pos);
					setApplicationName(app_name);
				}
			}
		}
	}

	public static void setApplicationName(String name)
	{
		if (name != null && name.trim().length() > 0)
		{
			name = name.trim();
			if (user_path != null && !name.equals(APPLICATION_NAME))
				System.out.println("**** SystemProperties::setApplicationName called too late! ****");
			APPLICATION_NAME = name;
		}
	}

	public static void setApplicationIdentifier(String application_id)
	{
		if (application_id != null && application_id.trim().length() > 0)
			APPLICATION_ID = application_id.trim();
	}

	public static void setApplicationEntryPoint(String entry_point)
	{
		if (entry_point != null && entry_point.trim().length() > 0)
			APPLICATION_ENTRY_POINT = entry_point.trim();
	}

	public static String getApplicationName()
	{
		return APPLICATION_NAME;
	}

	public static String getApplicationIdentifier()
	{
		return APPLICATION_ID;
	}

	public static String getApplicationEntryPoint()
	{
		return APPLICATION_ENTRY_POINT;
	}

	public static String getUserPath()
	{
		String temp_user_path;
		if (user_path != null)
			return user_path;
		temp_user_path = System.getProperty("azureus.config.path");
		String s;
		if (temp_user_path == null)
			break MISSING_BLOCK_LABEL_118;
		if (!temp_user_path.endsWith(SEP))
			temp_user_path = (new StringBuilder()).append(temp_user_path).append(SEP).toString();
		File dir = new File(temp_user_path);
		if (!dir.exists())
			FileUtil.mkdirs(dir);
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getUserPath(Custom): user_path = ").append(temp_user_path).toString()));
		s = temp_user_path;
		user_path = temp_user_path;
		return s;
		try
		{
			PlatformManager platformManager = PlatformManagerFactory.getPlatformManager();
			temp_user_path = (new StringBuilder()).append(platformManager.getLocation(1L).getPath()).append(SEP).toString();
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getUserPath: user_path = ").append(temp_user_path).toString()));
		}
		catch (Throwable e)
		{
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, "Unable to retrieve user config path from the platform manager. Make sure aereg.dll is present."));
		}
		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, (new StringBuilder()).append("Using user config path from APPDATA env var instead: ").append(temp_user_path).toString()));
				} else
				{
					temp_user_path = (new StringBuilder()).append(userhome).append(SEP).append("Application Data").toString();
					if (Logger.isEnabled())
						Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("Using user config path from java user.home var instead: ").append(temp_user_path).toString()));
				}
				temp_user_path = (new StringBuilder()).append(temp_user_path).append(SEP).append(APPLICATION_NAME).append(SEP).toString();
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getUserPath(Win): user_path = ").append(temp_user_path).toString()));
			} else
			if (Constants.isOSX)
			{
				temp_user_path = (new StringBuilder()).append(userhome).append(SEP).append(OSX_DEFAULT).append(SEP).append(APPLICATION_NAME).append(SEP).toString();
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getUserPath(Mac): user_path = ").append(temp_user_path).toString()));
			} else
			{
				temp_user_path = (new StringBuilder()).append(userhome).append(SEP).append(".").append(APPLICATION_NAME.toLowerCase()).append(SEP).toString();
				if (Logger.isEnabled())
					Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getUserPath(Unix): user_path = ").append(temp_user_path).toString()));
			}
		}
		File dir = new File(temp_user_path);
		if (!dir.exists())
			FileUtil.mkdirs(dir);
		s = temp_user_path;
		user_path = temp_user_path;
		return s;
		Exception exception;
		exception;
		user_path = temp_user_path;
		throw exception;
	}

	public static String getApplicationPath()
	{
		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 = (new StringBuilder()).append(temp_app_path).append(SEP).toString();
		app_path = temp_app_path;
		return app_path;
	}

	public static boolean isJavaWebStartInstance()
	{
		String java_ws_prop = System.getProperty("azureus.javaws");
		return java_ws_prop != null && java_ws_prop.equals("true");
		Throwable e;
		e;
		return false;
	}

	public static String getEnvironmentalVariable(String _var)
	{
		Process p = null;
		Properties envVars = new Properties();
		Runtime r = Runtime.getRuntime();
		BufferedReader br = null;
		if (Constants.isWindows9598ME)
			return "";
		try
		{
			if (Constants.isWindows)
				p = r.exec("cmd.exe /c set");
			else
				p = r.exec("env");
			String system_encoding = LocaleUtil.getSingleton().getSystemEncoding();
			if (Logger.isEnabled())
				Logger.log(new LogEvent(LOGID, (new StringBuilder()).append("SystemProperties::getEnvironmentalVariable - ").append(_var).append(", system encoding = ").append(system_encoding).toString()));
			br = new BufferedReader(new InputStreamReader(p.getInputStream(), system_encoding), 8192);
			do
			{
				String line;
				if ((line = br.readLine()) == null)
					break;
				int idx = line.indexOf('=');
				if (idx >= 0)
				{
					String key = line.substring(0, idx);
					String value = line.substring(idx + 1);
					envVars.setProperty(key, value);
				}
			} while (true);
			br.close();
		}
		catch (Throwable t)
		{
			if (br != null)
				try
				{
					br.close();
				}
				catch (Exception ingore) { }
		}
		return envVars.getProperty(_var, "");
	}

	public static String getDocPath()
	{
		File fDocPath = null;
		try
		{
			PlatformManager platformManager = PlatformManagerFactory.getPlatformManager();
			fDocPath = platformManager.getLocation(3L);
		}
		catch (Throwable e) { }
		if (fDocPath == null)
			fDocPath = new File(getUserPath(), "Documents");
		return fDocPath.getAbsolutePath();
	}

	public static String getAzureusJarPath()
	{
		String str = getApplicationPath();
		if (Constants.isOSX)
			str = (new StringBuilder()).append(str).append(getApplicationName()).append(".app/Contents/Resources/Java/").toString();
		return (new StringBuilder()).append(str).append("Azureus2.jar").toString();
	}

	static 
	{
		LOGID = LogIDs.CORE;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -