diff --git a/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveInfoPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveInfoPanel.xaml.cs index 1a62a07..2a5ab58 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveInfoPanel.xaml.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ArchiveViewer/ArchiveInfoPanel.xaml.cs @@ -42,23 +42,33 @@ namespace QuickLook.Plugin.ArchiveViewer { LoadItemsFromArchive(path); - var folder = 0; + var folders = -1; // do not count root node var files = 0; ulong sizeU = 0L; _fileEntries.ForEach(e => { if (e.Value.IsFolder) - folder++; + folders++; else files++; sizeU += e.Value.Size; }); - var s = _solid ? " solid," : ""; + var s = _solid ? ", solid" : ""; + + string t; + var d = folders != 0 ? $"{folders} folders" : string.Empty; + var f = files != 0 ? $"{files} files" : string.Empty; + if (!string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(f)) + t = $", {d} and {f}"; + else if (string.IsNullOrEmpty(d) && string.IsNullOrEmpty(f)) + t = string.Empty; + else + t = $", {d}{f}"; archiveCount.Content = - $"{_type} archive,{s} {folder - 1} folders and {files} files"; // do not count root node + $"{_type} archive{s}{t}"; archiveSizeC.Content = $"Compressed size {_totalZippedSize.ToPrettySize(2)}"; archiveSizeU.Content = $"Uncompressed size {sizeU.ToPrettySize(2)}"; } diff --git a/QuickLook/Plugin/InfoPanel/InfoPanel.xaml.cs b/QuickLook/Plugin/InfoPanel/InfoPanel.xaml.cs index 8cb5d06..d60d5d4 100644 --- a/QuickLook/Plugin/InfoPanel/InfoPanel.xaml.cs +++ b/QuickLook/Plugin/InfoPanel/InfoPanel.xaml.cs @@ -71,17 +71,24 @@ namespace QuickLook.Plugin.InfoPanel } else if (Directory.Exists(path)) { - long totalDirsL; - long totalFilesL; - long totalSizeL; - - FileHelper.CountFolder(path, ref _stop, out totalDirsL, out totalFilesL, out totalSizeL); + FileHelper.CountFolder(path, ref _stop, + out long totalDirsL, out long totalFilesL, out long totalSizeL); if (!Stop) Dispatcher.Invoke(() => { + string t; + var d = totalDirsL != 0 ? $"{totalDirsL} folders" : string.Empty; + var f = totalFilesL != 0 ? $"{totalFilesL} files" : string.Empty; + if (!string.IsNullOrEmpty(d) && !string.IsNullOrEmpty(f)) + t = $"({d} and {f})"; + else if (string.IsNullOrEmpty(d) && string.IsNullOrEmpty(f)) + t = string.Empty; + else + t = $"({d}{f})"; + totalSize.Text = - $"{totalSizeL.ToPrettySize(2)} ({totalDirsL} folders and {totalFilesL} files)"; + $"{totalSizeL.ToPrettySize(2)} {t}"; }); } });