Added FTLUtilities.findUserDataDir()
This commit is contained in:
parent
d635ce0158
commit
b980f4cdf6
3 changed files with 36 additions and 2 deletions
|
@ -174,4 +174,37 @@ public class FTLUtilities {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the directory for user profiles and saved games, or null.
|
||||
*/
|
||||
public static File findUserDataDir() {
|
||||
|
||||
String xdgDataHome = System.getenv("XDG_DATA_HOME");
|
||||
if ( xdgDataHome == null )
|
||||
xdgDataHome = System.getProperty("user.home") +"/.local/share";
|
||||
|
||||
File[] candidates = new File[] {
|
||||
// Windows XP
|
||||
new File( System.getProperty("user.home") +"/My Documents/My Games/FasterThanLight" ),
|
||||
// Windows Vista/7
|
||||
new File( System.getProperty("user.home") +"/Documents/My Games/FasterThanLight" ),
|
||||
// Linux
|
||||
new File( xdgDataHome +"/FasterThanLight" ),
|
||||
// OSX
|
||||
new File( System.getProperty("user.home") +"/Library/Application Support/FasterThanLight" )
|
||||
};
|
||||
|
||||
File result = null;
|
||||
|
||||
for ( File candidate : candidates ) {
|
||||
if ( candidate.isDirectory() && candidate.exists() ) {
|
||||
result = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
|||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import net.vhati.modmanager.core.EmptyAwareSAXHandlerFactory;
|
||||
import net.vhati.modmanager.core.Report;
|
||||
import net.vhati.modmanager.core.Report.ReportMessage;
|
||||
import net.vhati.modmanager.core.SloppyXMLParser;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue