# HG changeset patch # User Jason Maltzen # Date 2015-12-26 03:01:23 # Node ID 501aa95c46d731f22c066c31472202c866ead46b # Parent 523f1d42fb96b07565088d3b00183a4339932f76 Add more search paths to FileUtils for updated data folder locations. diff --git a/FileUtils.cs b/FileUtils.cs --- a/FileUtils.cs +++ b/FileUtils.cs @@ -17,6 +17,22 @@ namespace DesertPaintLab { return dirPath; } + dirPath = System.IO.Path.Combine( + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "data", + dirname); + if (!System.IO.Directory.Exists(dirPath)) + { + // not found + dirPath = null; + } + // try "Resources" in case this is a Mac app bundle + dirPath = System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", dirname); + if (System.IO.Directory.Exists(dirPath)) + { + return dirPath; + } // try "Resources" in case this is a Mac app bundle dirPath = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Resources), dirname); @@ -26,6 +42,15 @@ namespace DesertPaintLab } dirPath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "Resources", "data", + dirname); + if (!System.IO.Directory.Exists(dirPath)) + { + // not found + dirPath = null; + } + dirPath = System.IO.Path.Combine( + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Resources", dirname); if (!System.IO.Directory.Exists(dirPath)) @@ -38,11 +63,25 @@ namespace DesertPaintLab public static string FindApplicationResourceFile(string filename) { + // start with the location of the executable string filePath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), filename); if (!System.IO.File.Exists(filePath)) { + filePath = System.IO.Path.Combine( + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "data", + filename); + } + if (!System.IO.File.Exists(filePath)) + { + // try "Resources/data" in case this is a Mac app bundle + filePath = System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.Resources), "data", filename); + } + if (!System.IO.File.Exists(filePath)) + { // try "Resources" in case this is a Mac app bundle filePath = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.Resources), filename); @@ -51,6 +90,13 @@ namespace DesertPaintLab { filePath = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), + "Resources", "data", + filename); + } + if (!System.IO.File.Exists(filePath)) + { + filePath = System.IO.Path.Combine( + System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Resources", filename); }