mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-01-14 07:06:15 +08:00
Use faster APIs for getting drive info
This commit is contained in:
@@ -6,6 +6,16 @@ namespace QuickLook.Plugin.InfoPanel
|
||||
{
|
||||
public static class FileHelper
|
||||
{
|
||||
public static void GetDriveSpace(string path, out long totalSpace, out long totalFreeSpace)
|
||||
{
|
||||
totalSpace = totalFreeSpace = 0L;
|
||||
|
||||
var root = new DriveInfo(Path.GetPathRoot(path));
|
||||
|
||||
totalSpace = root.TotalSize;
|
||||
totalFreeSpace = root.AvailableFreeSpace;
|
||||
}
|
||||
|
||||
public static void CountFolder(string root, ref bool stop, out long totalDirs, out long totalFiles,
|
||||
out long totalSize)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,19 @@ namespace QuickLook.Plugin.InfoPanel
|
||||
|
||||
Dispatcher.Invoke(() => { totalSize.Text = size.ToPrettySize(2); });
|
||||
}
|
||||
else if (Path.GetPathRoot(path) == path) // is this a drive?
|
||||
{
|
||||
long totalSpace;
|
||||
long totalFreeSpace;
|
||||
|
||||
FileHelper.GetDriveSpace(path, out totalSpace, out totalFreeSpace);
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
totalSize.Text =
|
||||
$"Capacity {totalSpace.ToPrettySize(2)}, {totalFreeSpace.ToPrettySize(2)} available";
|
||||
});
|
||||
}
|
||||
else if (Directory.Exists(path))
|
||||
{
|
||||
long totalDirsL;
|
||||
|
||||
Reference in New Issue
Block a user