From 8789b7efa816aab0f4ce9d3149c26b8033e0b0a5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 2 Sep 2021 18:54:56 -0400 Subject: prepare path utilities for the upcoming Stardew Valley 1.5.5 The game will use Linux-style paths for assets on all platforms, which will break the current equivalence between path and asset name formats. --- src/SMAPI/Utilities/PathUtilities.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Utilities') diff --git a/src/SMAPI/Utilities/PathUtilities.cs b/src/SMAPI/Utilities/PathUtilities.cs index 19f16ea9..541b163c 100644 --- a/src/SMAPI/Utilities/PathUtilities.cs +++ b/src/SMAPI/Utilities/PathUtilities.cs @@ -6,6 +6,13 @@ namespace StardewModdingAPI.Utilities /// Provides utilities for normalizing file paths. public static class PathUtilities { + /********* + ** Accessors + *********/ + /// The preferred directory separator character in an asset key. + public static char PreferredAssetSeparator { get; } = ToolkitPathUtilities.PreferredAssetSeparator; + + /********* ** Public methods *********/ @@ -18,8 +25,16 @@ namespace StardewModdingAPI.Utilities return ToolkitPathUtilities.GetSegments(path, limit); } - /// Normalize separators in a file path. + /// Normalize an asset name to match how MonoGame's content APIs would normalize and cache it. + /// The asset name to normalize. + public static string NormalizeAssetName(string assetName) + { + return ToolkitPathUtilities.NormalizeAssetName(assetName); + } + + /// Normalize separators in a file path for the current platform. /// The file path to normalize. + /// This should only be used for file paths. For asset names, use instead. [Pure] public static string NormalizePath(string path) { -- cgit