Case-sensitivity checks on Windows
Should prevent "TigerThresher" from happening again.
This commit is contained in:
@@ -184,6 +184,7 @@ namespace Barotrauma
|
|||||||
spritePath = spritePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : "");
|
spritePath = spritePath.Replace("[GENDER]", (this.gender == Gender.Female) ? "f" : "");
|
||||||
spritePath = spritePath.Replace("[HEADID]", HeadSpriteId.ToString());
|
spritePath = spritePath.Replace("[HEADID]", HeadSpriteId.ToString());
|
||||||
|
|
||||||
|
ToolBox.IsProperFilenameCase(spritePath);
|
||||||
string fileName = Path.GetFileNameWithoutExtension(spritePath);
|
string fileName = Path.GetFileNameWithoutExtension(spritePath);
|
||||||
|
|
||||||
//go through the files in the directory to find a matching sprite
|
//go through the files in the directory to find a matching sprite
|
||||||
|
|||||||
@@ -748,6 +748,8 @@ namespace Barotrauma
|
|||||||
DebugConsole.ThrowError("TutorialSub.sub not found!");
|
DebugConsole.ThrowError("TutorialSub.sub not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "testasd":
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NewMessage("Command not found", Color.Red);
|
NewMessage("Command not found", Color.Red);
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ namespace Barotrauma
|
|||||||
componentStyles = new Dictionary<string, GUIComponentStyle>();
|
componentStyles = new Dictionary<string, GUIComponentStyle>();
|
||||||
|
|
||||||
XDocument doc;
|
XDocument doc;
|
||||||
try { doc = XDocument.Load(file); }
|
try
|
||||||
|
{
|
||||||
|
ToolBox.IsProperFilenameCase(file);
|
||||||
|
doc = XDocument.Load(file);
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Loading style \"" + file + "\" failed", e);
|
DebugConsole.ThrowError("Loading style \"" + file + "\" failed", e);
|
||||||
|
|||||||
@@ -973,6 +973,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ToolBox.IsProperFilenameCase(file);
|
||||||
doc = XDocument.Load(file);
|
doc = XDocument.Load(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,55 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static class ToolBox
|
public static class ToolBox
|
||||||
{
|
{
|
||||||
|
public static bool IsProperFilenameCase(string filename)
|
||||||
|
{
|
||||||
|
char[] delimiters = { '/','\\' };
|
||||||
|
string[] subDirs = filename.Split(delimiters);
|
||||||
|
string originalFilename = filename;
|
||||||
|
filename = "";
|
||||||
|
|
||||||
|
for (int i=0;i<subDirs.Length-1;i++)
|
||||||
|
{
|
||||||
|
filename += subDirs[i] + "/";
|
||||||
|
|
||||||
|
if (i == subDirs.Length - 2)
|
||||||
|
{
|
||||||
|
string[] filePaths = Directory.GetFiles(filename);
|
||||||
|
if (filePaths.Any(s => s.Equals(filename + subDirs[i + 1], StringComparison.Ordinal)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (filePaths.Any(s => s.Equals(filename + subDirs[i + 1], StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(originalFilename + " has incorrect case!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] dirPaths = Directory.GetDirectories(filename);
|
||||||
|
|
||||||
|
if (!dirPaths.Any(s => s.Equals(filename+subDirs[i+1],StringComparison.Ordinal)))
|
||||||
|
{
|
||||||
|
if (dirPaths.Any(s => s.Equals(filename + subDirs[i + 1], StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(originalFilename + " has incorrect case!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError(originalFilename + " doesn't exist!");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static XDocument TryLoadXml(string filePath)
|
public static XDocument TryLoadXml(string filePath)
|
||||||
{
|
{
|
||||||
XDocument doc;
|
XDocument doc;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
IsProperFilenameCase(filePath);
|
||||||
doc = XDocument.Load(filePath);
|
doc = XDocument.Load(filePath);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
Reference in New Issue
Block a user