mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
[Android] Fix a situation within the FolderBrowser where the application would crash. listFiles() returns null when either the File object it's called on isn't a directory or if an I/O error happens (in their infinite wisdom, they actually thought NOT throwing an exception was a cool way to handle this. How about that?). In the case of trying to access system directories as a normal user, an I/O error will occur due to permission access rights. This fixes that.
This commit is contained in:
@ -48,12 +48,15 @@ public final class FolderBrowser extends ListFragment
|
|||||||
{
|
{
|
||||||
m_activity.setTitle(getString(R.string.current_dir) + currDir.getName());
|
m_activity.setTitle(getString(R.string.current_dir) + currDir.getName());
|
||||||
File[] dirs = currDir.listFiles();
|
File[] dirs = currDir.listFiles();
|
||||||
List<FolderBrowserItem>dir = new ArrayList<FolderBrowserItem>();
|
List<FolderBrowserItem> dir = new ArrayList<FolderBrowserItem>();
|
||||||
List<FolderBrowserItem>fls = new ArrayList<FolderBrowserItem>();
|
List<FolderBrowserItem> fls = new ArrayList<FolderBrowserItem>();
|
||||||
|
|
||||||
// Supported extensions to filter by
|
// Supported extensions to filter by
|
||||||
Set<String> validExts = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
|
Set<String> validExts = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
|
||||||
|
|
||||||
|
// If dirs is null, then we don't have access permissions to the selected folder.
|
||||||
|
if (dirs != null)
|
||||||
|
{
|
||||||
// Search for any directories or files within the current dir.
|
// Search for any directories or files within the current dir.
|
||||||
for(File entry : dirs)
|
for(File entry : dirs)
|
||||||
{
|
{
|
||||||
@ -83,6 +86,7 @@ public final class FolderBrowser extends ListFragment
|
|||||||
Log.e("FolderBrowser", ex.toString());
|
Log.e("FolderBrowser", ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(dir);
|
Collections.sort(dir);
|
||||||
Collections.sort(fls);
|
Collections.sort(fls);
|
||||||
|
Reference in New Issue
Block a user