Skip to content

Commit d38e5f1

Browse files
committed
- Fixed UnauthorizedAccessException on iOS
- Tiny performance optimization
1 parent ace9a49 commit d38e5f1

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

Plugins/SimpleFileBrowser/Android/FBCallbackHelper.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ private void Update()
3131
{
3232
try
3333
{
34+
Action temp;
3435
lock( this )
3536
{
36-
Action temp = mainThreadAction;
37+
temp = mainThreadAction;
3738
mainThreadAction = null;
38-
temp();
3939
}
40+
41+
temp();
4042
}
4143
finally
4244
{

Plugins/SimpleFileBrowser/README.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= Simple File Browser (v1.7.1) =
1+
= Simple File Browser (v1.7.2) =
22

33
Documentation: https://github.com/yasirkula/UnitySimpleFileBrowser
44
FAQ: https://github.com/yasirkula/UnitySimpleFileBrowser#faq

Plugins/SimpleFileBrowser/Scripts/EventSystemHandler.cs

-2
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ private void OnDisable()
4848

4949
private void OnSceneLoaded( Scene scene, LoadSceneMode mode )
5050
{
51-
#if UNITY_2017_2_OR_NEWER
5251
DeactivateEventSystem();
53-
#endif
5452
ActivateEventSystemIfNeeded();
5553
}
5654

Plugins/SimpleFileBrowser/Scripts/FileBrowser.cs

+5-10
Original file line numberDiff line numberDiff line change
@@ -2102,16 +2102,16 @@ public void RefreshFiles( bool pathChanged )
21022102
}
21032103

21042104
// Returns whether or not the FileSystemEntry passes the file browser's filters and should be displayed in the files list
2105-
private bool FileSystemEntryMatchesFilters( FileSystemEntry item, bool allExtensionsHaveSingleSuffix )
2105+
private bool FileSystemEntryMatchesFilters( in FileSystemEntry item, bool allExtensionsHaveSingleSuffix )
21062106
{
2107+
if( ( item.Attributes & ignoredFileAttributes ) != 0 )
2108+
return false;
2109+
21072110
if( !item.IsDirectory )
21082111
{
21092112
if( m_pickerMode == PickMode.Folders )
21102113
return false;
21112114

2112-
if( ( item.Attributes & ignoredFileAttributes ) != 0 )
2113-
return false;
2114-
21152115
string extension = item.Extension;
21162116
if( excludedExtensionsSet.Contains( extension ) )
21172117
return false;
@@ -2130,11 +2130,6 @@ private bool FileSystemEntryMatchesFilters( FileSystemEntry item, bool allExtens
21302130
if( !filters[filtersDropdown.value].MatchesExtension( extension, !allExtensionsHaveSingleSuffix ) )
21312131
return false;
21322132
}
2133-
else
2134-
{
2135-
if( ( item.Attributes & ignoredFileAttributes ) != 0 )
2136-
return false;
2137-
}
21382133

21392134
if( m_searchString.Length > 0 && textComparer.IndexOf( item.Name, m_searchString, textCompareOptions ) < 0 )
21402135
return false;
@@ -2511,7 +2506,7 @@ internal void OnWindowDimensionsChanged( Vector2 size )
25112506
}
25122507
}
25132508

2514-
internal Sprite GetIconForFileEntry( FileSystemEntry fileInfo )
2509+
internal Sprite GetIconForFileEntry( in FileSystemEntry fileInfo )
25152510
{
25162511
return m_skin.GetIconForFileEntry( fileInfo, !AllExtensionsHaveSingleSuffix );
25172512
}

Plugins/SimpleFileBrowser/Scripts/FileBrowserHelpers.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace SimpleFileBrowser
55
{
6-
public struct FileSystemEntry
6+
public readonly struct FileSystemEntry
77
{
88
public readonly string Path;
99
public readonly string Name;
@@ -25,7 +25,15 @@ public FileSystemEntry( FileSystemInfo fileInfo, string extension )
2525
Path = fileInfo.FullName;
2626
Name = fileInfo.Name;
2727
Extension = extension;
28-
Attributes = fileInfo.Attributes;
28+
try
29+
{
30+
Attributes = fileInfo.Attributes;
31+
}
32+
catch
33+
{
34+
/// I've encountered UnauthorizedAccessException while accessing <see cref="FileSystemInfo.Attributes"/> on iOS.
35+
Attributes = ( fileInfo is DirectoryInfo ) ? FileAttributes.Directory : 0;
36+
}
2937
}
3038
}
3139

Plugins/SimpleFileBrowser/Scripts/UISkin.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ public void ApplyTo( Scrollbar scrollbar )
620620
scrollbar.image.color = m_scrollbarColor;
621621
}
622622

623-
public Sprite GetIconForFileEntry( FileSystemEntry fileInfo, bool extensionMayHaveMultipleSuffixes )
623+
public Sprite GetIconForFileEntry( in FileSystemEntry fileInfo, bool extensionMayHaveMultipleSuffixes )
624624
{
625625
if( !initializedFiletypeIcons )
626626
InitializeFiletypeIcons();

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.yasirkula.simplefilebrowser",
33
"displayName": "Simple File Browser",
4-
"version": "1.7.1",
4+
"version": "1.7.2",
55
"documentationUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser",
66
"changelogUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/releases",
77
"licensesUrl": "https://github.com/yasirkula/UnitySimpleFileBrowser/blob/master/LICENSE.txt",

0 commit comments

Comments
 (0)