Added fallback method to use only OS path instead of OS+platform

This commit is contained in:
Ziver Koc 2022-05-20 12:03:27 +02:00
parent 6217c838a7
commit f067708614

View file

@ -24,7 +24,10 @@
package zutil.osal; package zutil.osal;
import zutil.log.LogUtil;
import java.io.File; import java.io.File;
import java.util.logging.Logger;
/** /**
@ -46,7 +49,12 @@ import java.io.File;
* - win-x86/ * - win-x86/
* </pre> * </pre>
*/ */
public class MultiPlatformBinaryManager { public class OSALBinaryManager {
private static final Logger logger = LogUtil.getLogger();
private OSALBinaryManager() {}
/** /**
* *
@ -87,8 +95,15 @@ public class MultiPlatformBinaryManager {
case Windows: binary += ".exe"; break; case Windows: binary += ".exe"; break;
} }
String platform = os + "-" + arch; File platformPath = new File(root, os + "-" + arch);
File platformPath = new File(root, platform); if (!platformPath.exists())
platformPath = new File(root, os); // if platform is not available, try the generic OS path
if (platformPath.exists())
return new File(platformPath, binary); return new File(platformPath, binary);
else {
logger.fine("Unable to find platform(" + os + " or " + os + "-" + arch + ") specific path under: " + root);
return null;
}
} }
} }