mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +00:00
Attempt to improve Unix filesystem support
Add some new methods to PK3StructuredReader and DirectoryReader, which get the filename with the correct case, and get a file at a particular path. Replace backslashes in modeldef model paths with forward slashes, instead of doing the opposite, which was preventing some models from loading. I don't know whether or not this is a good solution or not, since I don't know the UDB codebase very well.
This commit is contained in:
parent
c047b98ba4
commit
42be899204
3 changed files with 38 additions and 38 deletions
|
@ -467,12 +467,12 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
internal override MemoryStream LoadFile(string filename)
|
internal override MemoryStream LoadFile(string filename)
|
||||||
{
|
{
|
||||||
MemoryStream s = null;
|
MemoryStream s = null;
|
||||||
|
string casecorrectfilename = GetCorrectCaseForFile(filename);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock(this)
|
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)
|
catch(Exception e)
|
||||||
|
@ -514,6 +514,11 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
return tempfile;
|
return tempfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override string GetCorrectCaseForFile(string filepathname)
|
||||||
|
{
|
||||||
|
return files.GetFileInfo(filepathname).filepathname;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Compiling (mxd)
|
#region ================== Compiling (mxd)
|
||||||
|
|
|
@ -501,17 +501,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
if(filename.IndexOf('.') > -1)
|
if(filename.IndexOf('.') > -1)
|
||||||
{
|
{
|
||||||
string fullname = Path.Combine(pathname, filename);
|
allfilenames = GetFileAtPath(filename, pathname, "DECORATE");
|
||||||
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 + "\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
||||||
|
@ -545,17 +535,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
if (filename.IndexOf('.') > -1)
|
if (filename.IndexOf('.') > -1)
|
||||||
{
|
{
|
||||||
string fullname = Path.Combine(pathname, filename);
|
allfilenames = GetFileAtPath(filename, pathname, "ZSCRIPT");
|
||||||
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 + "\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
||||||
|
@ -589,17 +569,7 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
|
|
||||||
if (filename.IndexOf('.') > -1)
|
if (filename.IndexOf('.') > -1)
|
||||||
{
|
{
|
||||||
string fullname = Path.Combine(pathname, filename);
|
allfilenames = GetFileAtPath(filename, pathname, "MODELDEF");
|
||||||
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 + "\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
|
||||||
|
@ -770,7 +740,26 @@ namespace CodeImp.DoomBuilder.Data
|
||||||
// Return result
|
// Return result
|
||||||
return images;
|
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
|
// This copies images from a collection unless they already exist in the list
|
||||||
private static void AddImagesToList(Dictionary<long, ImageData> targetlist, IEnumerable<ImageData> sourcelist)
|
private static void AddImagesToList(Dictionary<long, ImageData> targetlist, IEnumerable<ImageData> 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
|
//mxd. Archives and Folders don't have lump indices
|
||||||
internal override MemoryStream LoadFile(string name, int unused)
|
internal override MemoryStream LoadFile(string name, int unused)
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
{
|
{
|
||||||
case "path":
|
case "path":
|
||||||
parser.SkipWhitespace(true);
|
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))
|
if(string.IsNullOrEmpty(path))
|
||||||
{
|
{
|
||||||
parser.ReportError("Expected model path");
|
parser.ReportError("Expected model path");
|
||||||
|
|
Loading…
Reference in a new issue