Use StringView for Path operations

This commit is contained in:
Simon Lübeß
2025-07-04 00:12:19 +02:00
parent 1b46ff779a
commit 9dc6b585bd
2 changed files with 7 additions and 7 deletions
@@ -5,7 +5,7 @@ namespace System.IO;
extension Path
{
public static mixin GetScopedFullPath(String path)
public static mixin GetScopedFullPath(StringView path)
{
String fullPath = scope:: String(Path.MaxPath);
Path.GetFullPath(path, fullPath);
@@ -15,15 +15,15 @@ extension Path
/// Opens the file browser and selects the specified file.
/// @param path The path of the file to select.
public static extern Result<void> OpenFolderAndSelectItem(String path);
public static extern Result<void> OpenFolderAndSelectItem(StringView path);
/// Opens the file browser in the given directory.
/// @param directory The directory to show in the file browser.
public static extern Result<void> OpenFolder(String directory);
public static extern Result<void> OpenFolder(StringView directory);
/// Shows a dialog in which the user can select which program to open the given file with.
/// @param The Path of the file to open.
public static extern Result<void> OpenWithDialog(String filePath);
public static extern Result<void> OpenWithDialog(StringView filePath);
public static void Fixup(String path)
{
@@ -47,7 +47,7 @@ extension Path
{
/// Opens the file browser and selects the specified file.
/// @param path The path of the file to select.
public static override Result<void> OpenFolderAndSelectItem(String path)
public static override Result<void> OpenFolderAndSelectItem(StringView path)
{
String fullPath = GetScopedFullPath!(path);
@@ -59,7 +59,7 @@ extension Path
/// Opens the file browser in the given directory.
/// @param directory The directory to show in the file browser.
public static override Result<void> OpenFolder(String directory)
public static override Result<void> OpenFolder(StringView directory)
{
String fullPath = GetScopedFullPath!(directory);
@@ -69,7 +69,7 @@ extension Path
return scope SpawnedProcess().Start(processInfo);
}
public static override Result<void> OpenWithDialog(String filePath)
public static override Result<void> OpenWithDialog(StringView filePath)
{
String fullPath = GetScopedFullPath!(filePath);