Files
archived-discord-bot/CompatBot/Utils/PathUtils.cs
2025-11-15 23:17:44 +05:00

23 lines
583 B
C#

using System.IO;
namespace CompatBot.Utils;
public static class PathUtils
{
public static string[] GetSegments(string? path)
{
if (string.IsNullOrEmpty(path))
return [];
var result = new List<string>();
string segment;
do
{
segment = Path.GetFileName(path);
result.Add(segment is {Length: >0} ? segment : path);
path = Path.GetDirectoryName(path);
} while (segment is {Length: >0} && path is {Length: >0});
result.Reverse();
return result.ToArray();
}
}