Skip to content

Need Span overloads for Path APIs #24264

Closed
@JeremyKuhne

Description

@JeremyKuhne

In order to reduce allocations for path generation and manipulation we need Span overloads for System.IO.Path APIs.

Proposed API

namespace System.IO
{
    public static class Path
    {
        public static ReadOnlySpan<char> GetDirectoryName(ReadOnlySpan<char> path);
        public static ReadOnlySpan<char> GetExtension(ReadOnlySpan<char> path);
        public static ReadOnlySpan<char> GetFileName(ReadOnlySpan<char> path);
        public static ReadOnlySpan<char> GetFileNameWithoutExtension(ReadOnlySpan<char> path);
        public static ReadOnlySpan<char> GetPathRoot(ReadOnlySpan<char> path);
        public static bool HasExtension(ReadOnlySpan<char> path);
        public static bool IsPathFullyQualified(ReadOnlySpan<char> path);
        public static bool IsPathRooted(ReadOnlySpan<char> path);
    }
}

Implementation Notes

  • If the current APIs return null, these would return an empty span.

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.IO

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions