diff --git a/Source/Core/Data/DirectoryReader.cs b/Source/Core/Data/DirectoryReader.cs index 6183ee40..a79216c1 100755 --- a/Source/Core/Data/DirectoryReader.cs +++ b/Source/Core/Data/DirectoryReader.cs @@ -467,12 +467,12 @@ namespace CodeImp.DoomBuilder.Data internal override MemoryStream LoadFile(string filename) { MemoryStream s = null; - - try + string casecorrectfilename = GetCorrectCaseForFile(filename); + try { lock(this) { - s = new MemoryStream(File.ReadAllBytes(Path.Combine(location.location, filename))); + s = new MemoryStream(File.ReadAllBytes(Path.Combine(location.location, casecorrectfilename))); } } catch(Exception e) @@ -514,6 +514,11 @@ namespace CodeImp.DoomBuilder.Data return tempfile; } + protected override string GetCorrectCaseForFile(string filepathname) + { + return files.GetFileInfo(filepathname).filepathname; + } + #endregion #region ================== Compiling (mxd) diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs index 0c584725..01cbba9c 100755 --- a/Source/Core/Data/PK3StructuredReader.cs +++ b/Source/Core/Data/PK3StructuredReader.cs @@ -501,17 +501,7 @@ namespace CodeImp.DoomBuilder.Data if(filename.IndexOf('.') > -1) { - string fullname = Path.Combine(pathname, filename); - if(FileExists(fullname)) - { - allfilenames = new string[1]; - allfilenames[0] = Path.Combine(pathname, filename); - } - else - { - allfilenames = new string[0]; - General.ErrorLogger.Add(ErrorType.Warning, "Unable to load DECORATE file \"" + fullname + "\""); - } + allfilenames = GetFileAtPath(filename, pathname, "DECORATE"); } else allfilenames = GetAllFilesWithTitle(pathname, filename, false); @@ -545,17 +535,7 @@ namespace CodeImp.DoomBuilder.Data if (filename.IndexOf('.') > -1) { - string fullname = Path.Combine(pathname, filename); - if (FileExists(fullname)) - { - allfilenames = new string[1]; - allfilenames[0] = Path.Combine(pathname, filename); - } - else - { - allfilenames = new string[0]; - General.ErrorLogger.Add(ErrorType.Warning, "Unable to load ZSCRIPT file \"" + fullname + "\""); - } + allfilenames = GetFileAtPath(filename, pathname, "ZSCRIPT"); } else allfilenames = GetAllFilesWithTitle(pathname, filename, false); @@ -589,17 +569,7 @@ namespace CodeImp.DoomBuilder.Data if (filename.IndexOf('.') > -1) { - string fullname = Path.Combine(pathname, filename); - if (FileExists(fullname)) - { - allfilenames = new string[1]; - allfilenames[0] = Path.Combine(pathname, filename); - } - else - { - allfilenames = new string[0]; - General.ErrorLogger.Add(ErrorType.Warning, "Unable to load MODELDEF file \"" + fullname + "\""); - } + allfilenames = GetFileAtPath(filename, pathname, "MODELDEF"); } else allfilenames = GetAllFilesWithTitle(pathname, filename, false); @@ -770,7 +740,26 @@ namespace CodeImp.DoomBuilder.Data // Return result return images; } - + + protected string[] GetFileAtPath(string filename, string pathname, string type) + { + string[] allfilenames; + string fullname = Path.Combine(pathname, filename); + if (FileExists(fullname)) + { + allfilenames = new string[1]; + allfilenames[0] = Path.Combine(pathname, filename); + allfilenames[0] = GetCorrectCaseForFile(allfilenames[0]); + } + else + { + allfilenames = new string[0]; + General.ErrorLogger.Add(ErrorType.Warning, "Unable to load " + type + " file \"" + fullname + "\""); + } + + return allfilenames; + } + // This copies images from a collection unless they already exist in the list private static void AddImagesToList(Dictionary targetlist, IEnumerable sourcelist) { @@ -834,6 +823,12 @@ namespace CodeImp.DoomBuilder.Data } } + // Unix-like systems have case-sensitive filesystems. Use this to correct the case of a filename with the given path. + protected virtual string GetCorrectCaseForFile(string filepathname) + { + return filepathname; + } + //mxd. Archives and Folders don't have lump indices internal override MemoryStream LoadFile(string name, int unused) { diff --git a/Source/Core/ZDoom/ModeldefStructure.cs b/Source/Core/ZDoom/ModeldefStructure.cs index 088f9491..3da2e395 100755 --- a/Source/Core/ZDoom/ModeldefStructure.cs +++ b/Source/Core/ZDoom/ModeldefStructure.cs @@ -102,7 +102,7 @@ namespace CodeImp.DoomBuilder.ZDoom { case "path": parser.SkipWhitespace(true); - path = parser.StripTokenQuotes(parser.ReadToken(false)).Replace("/", "\\"); // Don't skip newline + path = parser.StripTokenQuotes(parser.ReadToken(false)).Replace("\\", "/"); // Don't skip newline if(string.IsNullOrEmpty(path)) { parser.ReportError("Expected model path");