Skip to content

Commit

Permalink
HasWindowsVolumeLabel: Avoid IndexOf, only supported on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Metapyziks committed Jul 30, 2024
1 parent e12f214 commit 033055d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Zio/FileSystems/PhysicalFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,10 @@ protected override string ConvertPathToInternalImpl(UPath path)

private static bool HasWindowsVolumeLabel(string path)
{
return path.IndexOf(":\\", StringComparison.Ordinal) == 1;
if (!IsOnWindows)
throw new NotSupportedException($"{nameof(HasWindowsVolumeLabel)} is only supported on Windows platforms.");

return path.Length >= 3 && path[1] == ':' && path[2] is '\\' or '/';
}

/// <inheritdoc />
Expand Down

0 comments on commit 033055d

Please sign in to comment.