Manually add built-in assets to disk image list, they may not exist on startup.

This commit is contained in:
James Sanford 2013-01-17 10:22:59 -08:00
parent 6a6b104d5e
commit 1e41eab9bf
2 changed files with 19 additions and 1 deletions

View File

@ -41,6 +41,17 @@ class AssetImages extends AsyncTask<Void, Void, Boolean> {
checkOldImagePath("System 6.hdv");
}
public static boolean isAssetFilename(final String filename) {
// We have to ignore any temporary files that we are working on, too.
if (filename.equals("System 6.hdv") ||
filename.equals("XMAS_DEMO.2MG") ||
filename.equals("tmp_System 6.hdv") ||
filename.equals("tmp_XMAS_DEMO.2MG")) {
return true;
}
return false;
}
public static String translateTitle(final String title) {
if (title.equals("System 6.hdv")) {
return "System 6";

View File

@ -51,7 +51,11 @@ public class DiskImageFragment extends SherlockDialogFragment {
String[] files = new File(dir).list();
if (files != null) {
for (String filename : files) {
if (!filename.startsWith(".") && DiskImage.isDiskImageFilename(filename)) {
// NOTE: Checking each filename against the known asset image names
// is a bit silly.
if (!filename.startsWith(".") &&
DiskImage.isDiskImageFilename(filename) &&
!AssetImages.isAssetFilename(filename)) {
final DiskImage image = DiskImage.fromPath(dir + "/" + filename);
if (image != null) {
mFoundImages.add(image);
@ -60,6 +64,9 @@ public class DiskImageFragment extends SherlockDialogFragment {
}
}
}
// NOTE HACK. These files may not exist yet, so we cannot use fromPath.
mFoundImages.add(new DiskImage("System 6.hdv", "s7d1", 3, DiskImage.BOOT_SLOT_7, DiskImage.ASSET));
mFoundImages.add(new DiskImage("XMAS_DEMO.2MG", "s5d1", 2, DiskImage.BOOT_SLOT_5, DiskImage.ASSET));
Collections.sort(mFoundImages);
}