Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ResPath CanonPath #5452

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Robust.Server/ServerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public sealed class ServerOptions
/// <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/");
Comment on lines +32 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to be consistent with client.


/// <summary>
/// Whether to disable mounting the "Resources/" folder on FULL_RELEASE.
Expand Down
2 changes: 1 addition & 1 deletion Robust.Shared/ContentPack/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public bool TryLoadModulesFrom(ResPath mountPath, string filterPrefix)
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;
Expand Down
5 changes: 4 additions & 1 deletion Robust.Shared/ContentPack/ResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,10 @@ public IEnumerable<ResPath> GetContentRoots()
{
if (root is DirLoader loader)
{
yield return new ResPath(loader.GetPath(new ResPath(@"/")));
// Sanitise platform specific path.
var rootDir = loader.GetPath(new ResPath(@"/")).Replace(Path.DirectorySeparatorChar, '/');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done by the dir loader, not the resource manager.


yield return new ResPath(rootDir);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Robust.Shared/Utility/ResPath.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using System.Text.Json.Serialization;
using JetBrains.Annotations;
Expand Down Expand Up @@ -64,6 +65,8 @@ namespace Robust.Shared.Utility;

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;
}

Expand Down
Loading