summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Utilities/PathUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/Utilities/PathUtilities.cs')
-rw-r--r--src/SMAPI/Framework/Utilities/PathUtilities.cs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Utilities/PathUtilities.cs b/src/SMAPI/Framework/Utilities/PathUtilities.cs
index 0233d796..51d45ebd 100644
--- a/src/SMAPI/Framework/Utilities/PathUtilities.cs
+++ b/src/SMAPI/Framework/Utilities/PathUtilities.cs
@@ -23,9 +23,12 @@ namespace StardewModdingAPI.Framework.Utilities
*********/
/// <summary>Get the segments from a path (e.g. <c>/usr/bin/boop</c> => <c>usr</c>, <c>bin</c>, and <c>boop</c>).</summary>
/// <param name="path">The path to split.</param>
- public static string[] GetSegments(string path)
+ /// <param name="limit">The number of segments to match. Any additional segments will be merged into the last returned part.</param>
+ public static string[] GetSegments(string path, int? limit = null)
{
- return path.Split(PathUtilities.PossiblePathSeparators, StringSplitOptions.RemoveEmptyEntries);
+ return limit.HasValue
+ ? path.Split(PathUtilities.PossiblePathSeparators, limit.Value, StringSplitOptions.RemoveEmptyEntries)
+ : path.Split(PathUtilities.PossiblePathSeparators, StringSplitOptions.RemoveEmptyEntries);
}
/// <summary>Normalise path separators in a file path.</summary>