mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix ResPath CanonPath (#5452)
* Fix ResPath CanonPath Apparently this is supposed to standardise to / but this isn't always the case. Alternatively we could just assert for performance reasons I'm good with either. The comment as written says this should happen. * assert * Fix bad respath input * review
This commit is contained in:
@@ -29,12 +29,12 @@ namespace Robust.Server
|
||||
/// <summary>
|
||||
/// Directory to load all assemblies from.
|
||||
/// </summary>
|
||||
public ResPath AssemblyDirectory { get; init; } = new(@"/Assemblies");
|
||||
public ResPath AssemblyDirectory { get; init; } = new(@"/Assemblies/");
|
||||
|
||||
/// <summary>
|
||||
/// Directory to load all prototypes from.
|
||||
/// </summary>
|
||||
public ResPath PrototypeDirectory { get; init; } = new(@"/Prototypes");
|
||||
public ResPath PrototypeDirectory { get; init; } = new(@"/Prototypes/");
|
||||
|
||||
/// <summary>
|
||||
/// Whether to disable mounting the "Resources/" folder on FULL_RELEASE.
|
||||
|
||||
@@ -60,7 +60,9 @@ namespace Robust.Shared.ContentPack
|
||||
|
||||
internal string GetPath(ResPath relPath)
|
||||
{
|
||||
return Path.GetFullPath(Path.Combine(_directory.FullName, relPath.ToRelativeSystemPath()));
|
||||
return Path.GetFullPath(Path.Combine(_directory.FullName, relPath.ToRelativeSystemPath()))
|
||||
// Sanitise platform-specific path and standardize it for engine use.
|
||||
.Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Robust.Shared.ContentPack
|
||||
var paths = new List<ResPath>();
|
||||
|
||||
foreach (var filePath in _res.ContentFindRelativeFiles(mountPath)
|
||||
.Where(p => !p.ToString().Contains('/') && p.Filename.StartsWith(filterPrefix) &&
|
||||
.Where(p => p.Filename.StartsWith(filterPrefix) &&
|
||||
p.Extension == "dll"))
|
||||
{
|
||||
var fullPath = mountPath / filePath;
|
||||
|
||||
@@ -379,7 +379,9 @@ namespace Robust.Shared.ContentPack
|
||||
{
|
||||
if (root is DirLoader loader)
|
||||
{
|
||||
yield return new ResPath(loader.GetPath(new ResPath(@"/")));
|
||||
var rootDir = loader.GetPath(new ResPath(@"/"));
|
||||
|
||||
yield return new ResPath(rootDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using JetBrains.Annotations;
|
||||
@@ -64,6 +65,8 @@ public readonly struct ResPath : IEquatable<ResPath>
|
||||
|
||||
public ResPath(string canonPath)
|
||||
{
|
||||
// Paths should never have non-standardised directory separators passed in, the caller should have already sanitised it.
|
||||
DebugTools.Assert(!canonPath.Contains('\\'));
|
||||
CanonPath = canonPath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user