Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Only adding fonts and images to list which are supported. Fixes #35.
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianSchoenbaechler committed Jul 27, 2018
1 parent ca3a788 commit e761357
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Assets/Volplane/Code/IO/FileManager.cs
Expand Up @@ -32,6 +32,19 @@ namespace Volplane.IO

public class FileManager
{
public static readonly IList<string> SupportedExtensions = new List<string> {
".jpg",
".jpeg",
".png",
".gif",
".otf",
".ttf",
".eot",
".woff",
".woff2",
".svg"
}.AsReadOnly();

/// <summary>
/// Generates a file list from a specific directory as JSONArray.
/// </summary>
Expand All @@ -47,14 +60,12 @@ public static JArray GetFileListFromDirectory(string directoryPath, string prefi

// Ignore meta files
directories = Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories)
.Where<string>(name => !name.EndsWith(".meta"));
.Where(file => SupportedExtensions.Any(ext => file.EndsWith(ext, StringComparison.OrdinalIgnoreCase)));

// Write all filenames from directory
// -> Replace backslash '\' to slash '/' for web and unix compatibility
foreach(string directory in directories)
{
list.Add(prefixPath + directory.Replace(directoryPath, "").Replace('\\', '/'));
}

return list;
}
Expand All @@ -76,9 +87,7 @@ public static string WriteJSON(Stream inputStream, string filePath, bool prettif
using(StreamReader reader = new StreamReader(inputStream, Encoding.UTF8))
{
while(!reader.EndOfStream)
{
sbContent.Append(reader.ReadLine());
}
}

return WriteJSON(JToken.Parse(sbContent.ToString()), filePath, prettify);
Expand Down Expand Up @@ -150,9 +159,7 @@ public static JToken ReadJSON(string filePath)
using(StreamReader reader = new StreamReader(fileStream, Encoding.UTF8))
{
while(!reader.EndOfStream)
{
sbContent.Append(reader.ReadLine());
}
}
}

Expand Down

0 comments on commit e761357

Please sign in to comment.