/
githubmirror
/
PowerToys
Обзор
Документация
Войти
/
githubmirror
/
PowerToys
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Shell/Helpers/ShellListPageHelpers.cs
48 строк
2 KB
Jiří Polášek
CmdPal: Ensure that directory paths passed from Bookmarks is quoted (#48955)
01 июл 2026, 07:24
Не верифицирован
01 июл 2026, 07:24
67a9fa2
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CmdPal.Common.Helpers; using Microsoft.CommandPalette.Extensions.Toolkit; namespace Microsoft.CmdPal.Ext.Shell.Helpers; public class ShellListPageHelpers { internal static bool FileExistInPath(string filename) { return FileExistInPath(filename, out var _); } internal static bool FileExistInPath(string filename, out string fullPath, CancellationToken? token = null) { return ShellHelpers.FileExistInPath(filename, out fullPath, token ?? CancellationToken.None); } /// <summary> /// This is a version of ParseExecutableAndArgs that handles whitespace in /// paths better. It will try to find the first matching executable in the /// input string. /// /// If the input is quoted, it will treat everything inside the quotes as /// the executable. If the input is not quoted, it will try to find the /// first segment that matches /// </summary> public static void NormalizeCommandLineAndArgs(string input, out string executable, out string arguments) { var normalized = CommandLineNormalizer.NormalizeCommandLine(input, allowDirectory: true); var segments = normalized.Split('\0', StringSplitOptions.RemoveEmptyEntries); executable = string.Empty; arguments = string.Empty; if (segments.Length == 0) { return; } executable = segments[0]; if (segments.Length > 1) { arguments = ShellArgumentBuilder.BuildArguments(segments[1..]); } } }