diff options
| author | Lioncash <mathew1800@gmail.com> | 2015-05-12 09:36:39 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2015-05-12 09:36:39 -0400 |
| commit | b036a4ea171710552d09445fa4c9aecada172327 (patch) | |
| tree | 79664c2a2badc8a4398253d6d395064490a4d40f /Source/Android/app/src/main/java | |
| parent | a6739c0960013d08131907055675a3cb95bc4af4 (diff) | |
| parent | 0fa0e55e2c374d3ce81100bd5e51d7088a3b2cd4 (diff) | |
Merge pull request #2405 from sigmabeta/master
Android: Fix a possible crash in the file browser.
Diffstat (limited to 'Source/Android/app/src/main/java')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java index 69b39438e8..b9c8a571cf 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java @@ -22,6 +22,7 @@ public class FileListItem implements Comparable<FileListItem> public FileListItem(File file) { mPath = file.getAbsolutePath(); + mFilename = file.getName(); if (file.isDirectory()) { @@ -29,23 +30,32 @@ public class FileListItem implements Comparable<FileListItem> } else { - String fileExtension = mPath.substring(mPath.lastIndexOf('.')); - - // Extensions to filter by. - Set<String> allowedExtensions = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs")); + String fileExtension = null; - // Check that the file has an appropriate extension before trying to read out of it. - if (allowedExtensions.contains(fileExtension)) + int extensionStart = mPath.lastIndexOf('.'); + if (extensionStart < 1) { - mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC; + // Ignore hidden files & files without extensions. + mType = TYPE_OTHER; } else { - mType = TYPE_OTHER; + fileExtension = mPath.substring(extensionStart); + + // The extensions we care about. + Set<String> allowedExtensions = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs")); + + // Check that the file has an extension we care about before trying to read out of it. + if (allowedExtensions.contains(fileExtension)) + { + mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC; + } + else + { + mType = TYPE_OTHER; + } } } - - mFilename = file.getName(); } public int getType() |
