@@ -122,9 +122,10 @@ public static object Load(System.Type objectType, ISerializationMethod serializa
122122 /// </summary>
123123 /// <param name="folderName">folder containing the save files</param>
124124 /// <param name="baseFolderPath">base path to the folder</param>
125+ /// <param name="extension">include only files with this extension</param>
125126 /// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
126127 /// <returns>list of file names</returns>
127- public static IEnumerable < string > EnumerateSavedFiles ( string folderName = null , string baseFolderPath = null , bool streamingAssets = false )
128+ public static IEnumerable < string > EnumerateSavedFiles ( string folderName = null , string baseFolderPath = null , string extension = null , bool streamingAssets = false )
128129 {
129130 var savePath = GetSavePath ( folderName , baseFolderPath , streamingAssets ) ;
130131
@@ -134,7 +135,8 @@ public static IEnumerable<string> EnumerateSavedFiles(string folderName = null,
134135 yield break ;
135136 }
136137
137- foreach ( var file in Directory . EnumerateFiles ( savePath , "*" , SearchOption . AllDirectories ) )
138+ var searchPattern = string . IsNullOrEmpty ( extension ) ? "*" : $ "*.{ extension } ";
139+ foreach ( var file in Directory . EnumerateFiles ( savePath , searchPattern , SearchOption . AllDirectories ) )
138140 {
139141 yield return Path . GetFileName ( file ) ;
140142 }
@@ -145,11 +147,12 @@ public static IEnumerable<string> EnumerateSavedFiles(string folderName = null,
145147 /// </summary>
146148 /// <param name="folderName"></param>
147149 /// <param name="baseFolderPath"></param>
150+ /// <param name="extension">include only files with this extension</param>
148151 /// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
149152 /// <returns>Array of file names</returns>
150- public static string [ ] GetSavedFiles ( string folderName = null , string baseFolderPath = null , bool streamingAssets = false )
153+ public static string [ ] GetSavedFiles ( string folderName = null , string baseFolderPath = null , string extension = null , bool streamingAssets = false )
151154 {
152- return EnumerateSavedFiles ( folderName , baseFolderPath ) . ToArray ( ) ;
155+ return EnumerateSavedFiles ( folderName , baseFolderPath , extension , streamingAssets ) . ToArray ( ) ;
153156 }
154157
155158 /// <summary>
@@ -158,12 +161,13 @@ public static string[] GetSavedFiles(string folderName = null, string baseFolder
158161 /// <param name="list">list to be populated with file names</param>
159162 /// <param name="folderName"></param>
160163 /// <param name="baseFolderPath"></param>
164+ /// <param name="extension">include only files with this extension</param>
161165 /// <param name="streamingAssets">Will use Application.streamingAssetsPath as base path if true otherwise Application.persistentDataPath</param>
162166 /// <returns>Array of file names</returns>
163- public static void GetSavedFiles ( List < string > list , string folderName = null , string baseFolderPath = null , bool streamingAssets = false )
167+ public static void GetSavedFiles ( List < string > list , string folderName = null , string baseFolderPath = null , string extension = null , bool streamingAssets = false )
164168 {
165169 list . Clear ( ) ;
166- list . AddRange ( EnumerateSavedFiles ( folderName , baseFolderPath , streamingAssets ) ) ;
170+ list . AddRange ( EnumerateSavedFiles ( folderName , baseFolderPath , extension streamingAssets ) ) ;
167171 }
168172
169173 /// <summary>
0 commit comments