DroidFish: Don't hard code the /data/data directory.

This commit is contained in:
Peter Osterlund 2014-07-13 11:42:05 +00:00
parent b61bfe14c9
commit f6d4e21b2e
3 changed files with 14 additions and 5 deletions

View File

@ -825,6 +825,12 @@ public class DroidFish extends Activity implements GUIInterface {
return true;
}
});
thinking.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openOptionsMenu();
}
});
custom1Button = (ImageButton)findViewById(R.id.custom1Button);
custom1ButtonActions.setImageButton(custom1Button, this);

View File

@ -36,8 +36,6 @@ public class ExternalEngine extends UCIEngineBase {
protected final Context context;
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 Process engineProc;
private Thread startupThread;
@ -62,10 +60,15 @@ public class ExternalEngine extends UCIEngineBase {
isRunning = false;
}
protected String internalSFPath() {
return context.getFilesDir().getAbsolutePath() + "/internal_sf";
}
/** @inheritDoc */
@Override
protected void startProcess() {
try {
String exePath = context.getFilesDir().getAbsolutePath() + "/engine.exe";
copyFile(engineFileName, new File(exePath));
chmod(exePath);
ProcessBuilder pb = new ProcessBuilder(exePath);
@ -256,7 +259,7 @@ public class ExternalEngine extends UCIEngineBase {
}
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()))
return;
if (to.exists())

View File

@ -105,7 +105,7 @@ public class InternalStockFish extends ExternalEngine {
// The checksum test is to avoid writing to /data unless necessary,
// 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);
if (oldCSum == newCSum)
return;
@ -132,6 +132,6 @@ public class InternalStockFish extends ExternalEngine {
if (os != null) try { os.close(); } catch (IOException ex) {}
}
writeCheckSum(new File(intSfPath), newCSum);
writeCheckSum(new File(internalSFPath()), newCSum);
}
}