Fixed unresolved symlinks when locating FTL resources

This commit is contained in:
Vhati 2017-11-26 01:19:44 -05:00
parent 738c05e853
commit 12f4db94f9

View file

@ -16,11 +16,13 @@ public class FTLUtilities {
/**
* Confirms the FTL resources dir exists and contains the dat files.
*
* Note: Do d.getCanonicalFile() to resolve any symlinks first!
*/
public static boolean isDatsDirValid( File d ) {
if ( !d.exists() || !d.isDirectory() ) return false;
if ( !new File(d, "data.dat").exists() ) return false;
if ( !new File(d, "resource.dat").exists() ) return false;
if ( !new File( d, "data.dat" ).exists() ) return false;
if ( !new File( d, "resource.dat" ).exists() ) return false;
return true;
}
@ -59,6 +61,10 @@ public class FTLUtilities {
File result = null;
for ( File candidate : candidates ) {
// Resolve symlinks.
try {candidate = candidate.getCanonicalFile();}
catch ( IOException e ) {continue;}
if ( isDatsDirValid( candidate ) ) {
result = candidate;
break;