From 0fa0e55e2c374d3ce81100bd5e51d7088a3b2cd4 Mon Sep 17 00:00:00 2001 From: Eder Bastos Date: Mon, 11 May 2015 21:40:42 -0400 Subject: [PATCH] Android: Fix a possible crash in the file browser if attempting to show a file with no extension. --- .../dolphinemu/model/FileListItem.java | 30 ++++++++++++------ Source/Android/code-style-java.jar | Bin 1534 -> 1542 bytes 2 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 public FileListItem(File file) { mPath = file.getAbsolutePath(); + mFilename = file.getName(); if (file.isDirectory()) { @@ -29,23 +30,32 @@ public class FileListItem implements Comparable } else { - String fileExtension = mPath.substring(mPath.lastIndexOf('.')); + String fileExtension = null; - // Extensions to filter by. - Set allowedExtensions = new HashSet(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs")); - - // 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 allowedExtensions = new HashSet(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() diff --git a/Source/Android/code-style-java.jar b/Source/Android/code-style-java.jar index 8140ad66f9d0318f07681facaddb87e9cc037492..04a041c0489f6bf0e73877deda94771fe6acdea9 100644 GIT binary patch delta 869 zcmV-r1DgE)3x*7k><#EZtVYK~Fv|7<006L&`6Pc^Z<{a_e&4S^Xit?Ex6@u4kw`AM z2_2UT$kyy(mPfq6$|VBR%fFu?geHNsi8fZM_!z!86K1vXCRtE>mCF--&)0L{>QbadlAoI#)v&VqilrcY=r)884xLoV<#CA*_+sJWL zV`NvTYa5op3%Jsat~KFvGuF@u%F_zJtSv}s4pah3?sgaH#EcL}|Zla}p?Q^`*IFijK~EG8!5@?Ua`k+ApNBHnSZV)FMlu zwnYhSCL)1avMs0IJ9(YV^P7~+XfnK*7Ervz7Q>E^(>v+!eJ4D|7JUGUw^DzS_R0&@ z<1aaYEN($UQ&3&9H-2Y0ExGWI#B39D04v|$zxiy_yyN^o>F!-4|5C2quZ;nDj5CJs z{TcI)#b7r<9`)xQJ2JGJp}n>BkJ;(I20JXi?vvMLVRoLqBW-QcmM`oG9m@r)Z*{Qs zvEKMkVreXY(GPzEP)h>@6aWVR2nYZHL9CM&1W5w{L9CNv1j7yJK&(c`L@>(s0ssK8 vlQIQ70|7y-lW_$b0TGjp1snqbL9COk1seig1e0+DA(QF_4hEP600000!h?}@ delta 901 zcmV;01A6?14E_s{>MBw_N!3j(Y-s`$ zhm=PIxQ)B$h~lZC;bFlzkH7B)V`3Ye#A<1X>YeA#+;is~-v=Oh$&}H|^I61%*p1jg zRFZJ+2l0nX_tq7M?*u_g<~&H^a{F8*nnDe%6MAKlbM;yjZryMJJCP`$`gvKywoPSo zY&d_^G3nSQRMoFc%b})06{2H9sSr+28zJ&we+Y4f<~EacjL}h!n*M^O@gT?+y&gX7eC6~Y#{PG z9lLAGQb!jK)v+~FjjE_mj*nMWjh97q9fdMR%vg}QcO2|a@=UF%vCKA5RSMp&Ly_+@V)N^_tRNb)vzQ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