Пример #1
0
        public static ReadOnlySpan<char> ParentDirectory(this ReadOnlySpan<char> filePath)
        {
            if (filePath.IsNullOrEmpty())
                return TypeConstants.NullStringSpan;

            var dirSep = filePath.IndexOf(PclExport.Instance.DirSep) != -1
                ? PclExport.Instance.DirSep
                : filePath.IndexOf(PclExport.Instance.AltDirSep) != -1
                    ? PclExport.Instance.AltDirSep
                    : (char)0;

            if (dirSep == 0)
                return TypeConstants.NullStringSpan;
            
            MemoryExtensions.TrimEnd(filePath, dirSep).SplitOnLast(dirSep, out var first, out _); 
            return first;
        }