All pastes #474185 Raw Edit

Something

public java v1 · immutable
·published 2007-05-06 17:48 UTC
rendered paste body
	public NTypeSettings()	{		/*		 * This is a bit of a hack because Java is incapable of accessing the correct		 * environment variables to get the "all users" application data directory,		 * typically "C:\Documents and Settings\All Users\Application Data"		 */		String suffix;		String os = System.getProperty("os.name");		dirBase = System.getenv("ALLUSERSPROFILE");		/*		 * On Vista, ALLUSERSPROFILE returns "C:\ProgramData", which is fine. On XP,		 * it returns "C:\Documents and Settings\All Users", so we need to add		 * "Application Data" (OR THE CURRENT LANGUAGE'S EQUIVALENT) to the path 		 */		if(os.equals("Windows Vista"))		{			suffix = "";		}		else		{			/*			 * APPDATA on XP returns "C:\Documents and Settings\CURRENTUSER\Application Data"			 * or the current language equivalent			 */			suffix = System.getenv("APPDATA");		}				if(dirBase == null || suffix == null || dirBase.equals("")) dirBase = ""; else		{			/*			 * We want to join the last part of APPDATA to ALLUSERSPROFILE, so for example			 * if ALLUSERSPROFILE is "C:\Documents and Settings\All Users\", and APPDATA is			 * "C:\Documents and Settings\CURRENT USER\Dati applicazioni" (Italian) then we			 * end up with "C:\Documents and Settings\All Users\Dati applicazioni" which			 * is the correct directory.			 */			if(!suffix.equals(""))			{				int lastIndex = suffix.lastIndexOf("\\");				if(lastIndex == suffix.length() - 1)					lastIndex = suffix.lastIndexOf("\\", suffix.length() - 2);				if(lastIndex != -1)					suffix = suffix.substring(lastIndex);				else					suffix = "";			}			// Create directories for N-Type			makeDir(dirBase + suffix + "/Riff-Raph");			makeDir(dirBase + suffix + "/Riff-Raph/N-Type");			dirBase += suffix + "/Riff-Raph/N-Type/";		}		// Create the profiles dir		makeDir(dirBase + "profiles");		NTypeSettingsProfile.setDirBase(dirBase);		init(dirBase + "settings.ini");	}