From 5b0c08e6485be686f81586617aecb6667ca81238 Mon Sep 17 00:00:00 2001 From: yasirkula Date: Thu, 9 Nov 2023 20:51:23 +0300 Subject: [PATCH] Fixed file browser not showing any contents in a folder if it contains a system-protected file/folder (happened with '.android_secure' folder on Android) --- Plugins/SimpleFileBrowser/README.txt | 2 +- .../Scripts/FileBrowserHelpers.cs | 23 +++++++++++++++---- package.json | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Plugins/SimpleFileBrowser/README.txt b/Plugins/SimpleFileBrowser/README.txt index 6de8f9a..c55fc1c 100644 --- a/Plugins/SimpleFileBrowser/README.txt +++ b/Plugins/SimpleFileBrowser/README.txt @@ -1,4 +1,4 @@ -= Simple File Browser (v1.6.2) = += Simple File Browser (v1.6.3) = Documentation: https://github.com/yasirkula/UnitySimpleFileBrowser FAQ: https://github.com/yasirkula/UnitySimpleFileBrowser#faq diff --git a/Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs b/Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs index 2216d0a..58a027f 100644 --- a/Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs +++ b/Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs @@ -239,14 +239,29 @@ public static FileSystemEntry[] GetEntriesInDirectory( string path, bool extract try { - FileSystemInfo[] items = new DirectoryInfo( path ).GetFileSystemInfos(); - FileSystemEntry[] result = new FileSystemEntry[items.Length]; + string[] files = Directory.GetFiles( path ); + string[] subDirectories = Directory.GetDirectories( path ); + FileSystemEntry[] result = new FileSystemEntry[files.Length + subDirectories.Length]; int index = 0; - for( int i = 0; i < items.Length; i++ ) + for( int i = 0; i < files.Length; i++ ) { try { - result[index] = new FileSystemEntry( items[i], FileBrowser.GetExtensionFromFilename( items[i].Name, extractOnlyLastSuffixFromExtensions ) ); + FileInfo fileInfo = new FileInfo( files[i] ); + result[index] = new FileSystemEntry( fileInfo, FileBrowser.GetExtensionFromFilename( fileInfo.Name, extractOnlyLastSuffixFromExtensions ) ); + index++; + } + catch( System.Exception e ) + { + Debug.LogException( e ); + } + } + + for( int i = 0; i < subDirectories.Length; i++ ) + { + try + { + result[index] = new FileSystemEntry( new DirectoryInfo( subDirectories[i] ), string.Empty ); index++; } catch( System.Exception e ) diff --git a/package.json b/package.json index c54d6d3..5d559af 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.simplefilebrowser", "displayName": "Simple File Browser", - "version": "1.6.2", + "version": "1.6.3", "documentationUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser", "changelogUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/releases", "licensesUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/blob/master/LICENSE.txt",