Last active
March 8, 2018 00:49
-
-
Save JeremyKuhne/19fcbe193661a6772d6d6643b6be031a to your computer and use it in GitHub Desktop.
New Path APIs in 2.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System.IO | |
{ | |
public static class 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 bool HasExtension(ReadOnlySpan<char> path); | |
public static bool IsPathFullyQualified(ReadOnlySpan<char> path); | |
public static bool IsPathRooted(ReadOnlySpan<char> path); | |
// Unlike the string overloads, GetPathRoot/DirectoryName will not normalize separators | |
public static ReadOnlySpan<char> GetPathRoot(ReadOnlySpan<char> path); | |
public static ReadOnlySpan<char> GetDirectoryName(ReadOnlySpan<char> path); | |
// Unlike Combine(), Join() methods do not consider rooting. They simply combine paths, ensuring that there | |
// is a directory separator between them. | |
public static string Join(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2); | |
public static string Join(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, ReadOnlySpan<char> path3); | |
public static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, Span<char> destination, out int charsWritten); | |
public static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, ReadOnlySpan<char> path3, Span<char> destination, out int charsWritten); | |
// This new overload allows resolving the path in a thread safe manner, using the basePath as the effective | |
// current directory to resolve paths that aren't fully qualified. | |
public static string GetFullPath(string path, string basePath); | |
// These is not new to 2.1, but it is relatively new and you may have missed it | |
public static string GetRelativePath(string relativeTo, string path); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment