mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 11:46:30 +02:00
Add find file plugin.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -30,13 +31,26 @@ namespace Wox.Infrastructure.MFTSearch
|
||||
{
|
||||
foreach (DriveInfo drive in DriveInfo.GetDrives())
|
||||
{
|
||||
IndexVolume(drive.VolumeLabel);
|
||||
IndexVolume(drive.Name.Replace("\\", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public static long IndexedFileCount
|
||||
{
|
||||
get { return cache.FileCount; }
|
||||
}
|
||||
public static long IndexedFolderCount
|
||||
{
|
||||
get { return cache.FolderCount; }
|
||||
}
|
||||
|
||||
public static List<MFTSearchRecord> Search(string item)
|
||||
{
|
||||
return null;
|
||||
if (string.IsNullOrEmpty(item)) return new List<MFTSearchRecord>();
|
||||
|
||||
List<USNRecord> found = cache.FindByName(item);
|
||||
found.ForEach(x => FillPath(x.VolumeName, x, cache));
|
||||
return found.ConvertAll(o => new MFTSearchRecord(o));
|
||||
}
|
||||
|
||||
private static void AddVolumeRootRecord(string volumeName, ref List<USNRecord> folders)
|
||||
|
||||
@@ -85,22 +85,19 @@ namespace Wox.Infrastructure.MFTSearch
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public List<USNRecord> FindByName(string filename, out long foundFileCnt, out long fountFolderCnt)
|
||||
public List<USNRecord> FindByName(string filename)
|
||||
{
|
||||
|
||||
filename = filename.ToLower();
|
||||
var fileQuery = from filesInVolumeDic in _volumes_files.Values
|
||||
from eachFilePair in filesInVolumeDic
|
||||
where eachFilePair.Value.Name.Contains(filename)
|
||||
where eachFilePair.Value.Name.ToLower().Contains(filename)
|
||||
select eachFilePair.Value;
|
||||
|
||||
var folderQuery = from fldsInVolumeDic in _volumes_folders.Values
|
||||
from eachFldPair in fldsInVolumeDic
|
||||
where eachFldPair.Value.Name.Contains(filename)
|
||||
where eachFldPair.Value.Name.ToLower().Contains(filename)
|
||||
select eachFldPair.Value;
|
||||
|
||||
foundFileCnt = fileQuery.Count();
|
||||
fountFolderCnt = folderQuery.Count();
|
||||
|
||||
List<USNRecord> result = new List<USNRecord>();
|
||||
|
||||
result.AddRange(fileQuery);
|
||||
|
||||
Reference in New Issue
Block a user