mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-15 10:22:40 +01:00
DroidFish: Don't hard code the /data/data directory.
This commit is contained in:
@@ -825,6 +825,12 @@ public class DroidFish extends Activity implements GUIInterface {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
thinking.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
openOptionsMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
custom1Button = (ImageButton)findViewById(R.id.custom1Button);
|
custom1Button = (ImageButton)findViewById(R.id.custom1Button);
|
||||||
custom1ButtonActions.setImageButton(custom1Button, this);
|
custom1ButtonActions.setImageButton(custom1Button, this);
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ public class ExternalEngine extends UCIEngineBase {
|
|||||||
protected final Context context;
|
protected final Context context;
|
||||||
|
|
||||||
private File engineFileName;
|
private File engineFileName;
|
||||||
protected static final String intSfPath = "/data/data/org.petero.droidfish/internal_sf";
|
|
||||||
private static final String exePath = "/data/data/org.petero.droidfish/engine.exe";
|
|
||||||
private final Report report;
|
private final Report report;
|
||||||
private Process engineProc;
|
private Process engineProc;
|
||||||
private Thread startupThread;
|
private Thread startupThread;
|
||||||
@@ -62,10 +60,15 @@ public class ExternalEngine extends UCIEngineBase {
|
|||||||
isRunning = false;
|
isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String internalSFPath() {
|
||||||
|
return context.getFilesDir().getAbsolutePath() + "/internal_sf";
|
||||||
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
@Override
|
@Override
|
||||||
protected void startProcess() {
|
protected void startProcess() {
|
||||||
try {
|
try {
|
||||||
|
String exePath = context.getFilesDir().getAbsolutePath() + "/engine.exe";
|
||||||
copyFile(engineFileName, new File(exePath));
|
copyFile(engineFileName, new File(exePath));
|
||||||
chmod(exePath);
|
chmod(exePath);
|
||||||
ProcessBuilder pb = new ProcessBuilder(exePath);
|
ProcessBuilder pb = new ProcessBuilder(exePath);
|
||||||
@@ -256,7 +259,7 @@ public class ExternalEngine extends UCIEngineBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void copyFile(File from, File to) throws IOException {
|
protected void copyFile(File from, File to) throws IOException {
|
||||||
new File(intSfPath).delete();
|
new File(internalSFPath()).delete();
|
||||||
if (to.exists() && (from.length() == to.length()) && (from.lastModified() == to.lastModified()))
|
if (to.exists() && (from.length() == to.length()) && (from.lastModified() == to.lastModified()))
|
||||||
return;
|
return;
|
||||||
if (to.exists())
|
if (to.exists())
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class InternalStockFish extends ExternalEngine {
|
|||||||
|
|
||||||
// The checksum test is to avoid writing to /data unless necessary,
|
// The checksum test is to avoid writing to /data unless necessary,
|
||||||
// on the assumption that it will reduce memory wear.
|
// on the assumption that it will reduce memory wear.
|
||||||
long oldCSum = readCheckSum(new File(intSfPath));
|
long oldCSum = readCheckSum(new File(internalSFPath()));
|
||||||
long newCSum = computeAssetsCheckSum(sfExe);
|
long newCSum = computeAssetsCheckSum(sfExe);
|
||||||
if (oldCSum == newCSum)
|
if (oldCSum == newCSum)
|
||||||
return;
|
return;
|
||||||
@@ -132,6 +132,6 @@ public class InternalStockFish extends ExternalEngine {
|
|||||||
if (os != null) try { os.close(); } catch (IOException ex) {}
|
if (os != null) try { os.close(); } catch (IOException ex) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeCheckSum(new File(intSfPath), newCSum);
|
writeCheckSum(new File(internalSFPath()), newCSum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user