From 7a49aac643ce4793d8e8f13cc82752876c6cdcf6 Mon Sep 17 00:00:00 2001 From: Jaime Bernardo Date: Fri, 28 Oct 2022 12:05:32 +0100 Subject: [PATCH] Support drives too --- installer/PowerToysSetup/Product.wxs | 3 +++ .../FileLocksmithLibInterop/FileLocksmith.cpp | 2 +- .../FileListToDescriptionConverter.cs | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/installer/PowerToysSetup/Product.wxs b/installer/PowerToysSetup/Product.wxs index ef3f5db748e4..4c617e370a96 100644 --- a/installer/PowerToysSetup/Product.wxs +++ b/installer/PowerToysSetup/Product.wxs @@ -900,6 +900,9 @@ + + + diff --git a/src/modules/FileLocksmith/FileLocksmithLibInterop/FileLocksmith.cpp b/src/modules/FileLocksmith/FileLocksmithLibInterop/FileLocksmith.cpp index d6ef73abefb6..ebec97e42376 100644 --- a/src/modules/FileLocksmith/FileLocksmithLibInterop/FileLocksmith.cpp +++ b/src/modules/FileLocksmith/FileLocksmithLibInterop/FileLocksmith.cpp @@ -55,7 +55,7 @@ std::vector find_processes_recursive(const std::vector0&&dir_kernel_name[dir_kernel_name.length()-1]!=L'\\' ? L"\\" : L""))) { return dir_path + kernel_name.substr(dir_kernel_name.size()); } diff --git a/src/modules/FileLocksmith/FileLocksmithUI/Converters/FileListToDescriptionConverter.cs b/src/modules/FileLocksmith/FileLocksmithUI/Converters/FileListToDescriptionConverter.cs index d38426e0afd4..4ea7687b13c3 100644 --- a/src/modules/FileLocksmith/FileLocksmithUI/Converters/FileListToDescriptionConverter.cs +++ b/src/modules/FileLocksmith/FileLocksmithUI/Converters/FileListToDescriptionConverter.cs @@ -18,13 +18,26 @@ public object Convert(object value, Type targetType, object parameter, string la { return string.Empty; } - else if (paths.Length == 1) + + string firstPath = paths[0]; + firstPath = Path.GetFileName(paths[0]); + if (string.IsNullOrEmpty(firstPath)) + { + firstPath = Path.GetDirectoryName(paths[0]); + } + + if (string.IsNullOrEmpty(firstPath)) + { + firstPath = Path.GetPathRoot(paths[0]); + } + + if (paths.Length == 1) { - return Path.GetFileName(paths[0]); + return firstPath; } else { - return Path.GetFileName(paths[0]) + "; +" + (paths.Length - 1); + return firstPath + "; +" + (paths.Length - 1); } }