-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[FileStream] handle UNC and device paths #54483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ internal static partial class PathInternal | |
| internal const string DirectorySeparatorCharAsString = "\\"; | ||
|
|
||
| internal const string ExtendedPathPrefix = @"\\?\"; | ||
| internal const string NtPrefix = @"\??\"; | ||
| internal const string UncPathPrefix = @"\\"; | ||
| internal const string UncExtendedPrefixToInsert = @"?\UNC\"; | ||
| internal const string UncExtendedPathPrefix = @"\\?\UNC\"; | ||
|
|
@@ -409,5 +410,34 @@ internal static bool IsEffectivelyEmpty(ReadOnlySpan<char> path) | |
| } | ||
| return true; | ||
| } | ||
|
|
||
| // this method works only for `fullPath` returned by Path.GetFullPath | ||
| // currently we don't have interest in supporting relative paths | ||
| internal static void DosToNtPath(ReadOnlySpan<char> fullPath, ref ValueStringBuilder vsb) | ||
adamsitnik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| vsb.Append(NtPrefix); | ||
|
|
||
| if (fullPath.Length >= 3 && fullPath[0] == '\\' && fullPath[1] == '\\') | ||
| { | ||
| // \\.\ (Device) or \\?\ (NtPath) | ||
adamsitnik marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (fullPath.Length >= 4 && fullPath[3] == '\\' && (fullPath[2] == '.' || fullPath[2] == '?')) | ||
| { | ||
| vsb.Append(fullPath.Slice(NtPrefix.Length)); | ||
| } | ||
| else // \\ (UNC) | ||
| { | ||
| vsb.Append(@"UNC\"); | ||
| vsb.Append(fullPath.Slice(2)); | ||
| } | ||
| } | ||
| else if (fullPath.Length >= 4 && fullPath[0] == '\\' && fullPath[1] == '?' && fullPath[2] == '?' && fullPath[3] == '\\') // \??\ | ||
| { | ||
| vsb.Append(fullPath.Slice(NtPrefix.Length)); | ||
| } | ||
| else | ||
| { | ||
| vsb.Append(fullPath); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.