diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs b/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs deleted file mode 100644 index 9c86ecdd75..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/Bookmark.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Wox.Infrastructure; - -namespace Wox.Plugin.BrowserBookmark -{ - public class Bookmark : IEquatable, IEqualityComparer - { - private string m_Name; - public string Name - { - get - { - return m_Name; - } - set - { - m_Name = value; - PinyinName = m_Name.Unidecode(); - } - } - public string PinyinName { get; private set; } - public string Url { get; set; } - public string Source { get; set; } - public int Score { get; set; } - - /* TODO: since Source maybe unimportant, we just need to compare Name and Url */ - public bool Equals(Bookmark other) - { - return Equals(this, other); - } - - public bool Equals(Bookmark x, Bookmark y) - { - if (Object.ReferenceEquals(x, y)) return true; - if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) - return false; - - return x.Name == y.Name && x.Url == y.Url; - } - - public int GetHashCode(Bookmark bookmark) - { - if (Object.ReferenceEquals(bookmark, null)) return 0; - int hashName = bookmark.Name == null ? 0 : bookmark.Name.GetHashCode(); - int hashUrl = bookmark.Url == null ? 0 : bookmark.Url.GetHashCode(); - return hashName ^ hashUrl; - } - - public override int GetHashCode() - { - return GetHashCode(this); - } - } -} diff --git a/Plugins/Wox.Plugin.BrowserBookmark/ChromeBookmarks.cs b/Plugins/Wox.Plugin.BrowserBookmark/ChromeBookmarks.cs deleted file mode 100644 index 16e5c328cb..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/ChromeBookmarks.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; - -namespace Wox.Plugin.BrowserBookmark -{ - public class ChromeBookmarks - { - private List bookmarks = new List(); - - public List GetBookmarks() - { - bookmarks.Clear(); - LoadChromeBookmarks(); - - return bookmarks; - } - - private void ParseChromeBookmarks(String path, string source) - { - if (!File.Exists(path)) return; - - string all = File.ReadAllText(path); - Regex nameRegex = new Regex("\"name\": \"(?.*?)\""); - MatchCollection nameCollection = nameRegex.Matches(all); - Regex typeRegex = new Regex("\"type\": \"(?.*?)\""); - MatchCollection typeCollection = typeRegex.Matches(all); - Regex urlRegex = new Regex("\"url\": \"(?.*?)\""); - MatchCollection urlCollection = urlRegex.Matches(all); - - List names = (from Match match in nameCollection select match.Groups["name"].Value).ToList(); - List types = (from Match match in typeCollection select match.Groups["type"].Value).ToList(); - List urls = (from Match match in urlCollection select match.Groups["url"].Value).ToList(); - - int urlIndex = 0; - for (int i = 0; i < names.Count; i++) - { - string name = DecodeUnicode(names[i]); - string type = types[i]; - if (type == "url") - { - string url = urls[urlIndex]; - urlIndex++; - - if (url == null) continue; - if (url.StartsWith("javascript:", StringComparison.OrdinalIgnoreCase)) continue; - if (url.StartsWith("vbscript:", StringComparison.OrdinalIgnoreCase)) continue; - - bookmarks.Add(new Bookmark() - { - Name = name, - Url = url, - Source = source - }); - } - } - } - - private void LoadChromeBookmarks(string path, string name) - { - if (!Directory.Exists(path)) return; - var paths = Directory.GetDirectories(path); - - foreach (var profile in paths) - { - if (File.Exists(Path.Combine(profile, "Bookmarks"))) - ParseChromeBookmarks(Path.Combine(profile, "Bookmarks"), name + (Path.GetFileName(profile) == "Default" ? "" : (" (" + Path.GetFileName(profile) + ")"))); - } - } - - private void LoadChromeBookmarks() - { - String platformPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - LoadChromeBookmarks(Path.Combine(platformPath, @"Google\Chrome\User Data"), "Google Chrome"); - LoadChromeBookmarks(Path.Combine(platformPath, @"Google\Chrome SxS\User Data"), "Google Chrome Canary"); - LoadChromeBookmarks(Path.Combine(platformPath, @"Chromium\User Data"), "Chromium"); - } - - private String DecodeUnicode(String dataStr) - { - Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})"); - return reg.Replace(dataStr, m => ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString()); - } - } -} \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs b/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs deleted file mode 100644 index fec331a76e..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/FirefoxBookmarks.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data.SQLite; -using System.IO; -using System.Linq; - -namespace Wox.Plugin.BrowserBookmark -{ - public class FirefoxBookmarks - { - private const string queryAllBookmarks = @"SELECT moz_places.url, moz_bookmarks.title - FROM moz_places - INNER JOIN moz_bookmarks ON ( - moz_bookmarks.fk NOT NULL AND moz_bookmarks.fk = moz_places.id - ) - ORDER BY moz_places.visit_count DESC - "; - - private const string dbPathFormat = "Data Source ={0};Version=3;New=False;Compress=True;"; - - /// - /// Searches the places.sqlite db and returns all bookmarks - /// - public List GetBookmarks() - { - // Return empty list if the places.sqlite file cannot be found - if (string.IsNullOrEmpty(PlacesPath) || !File.Exists(PlacesPath)) - return new List(); - - // create the connection string and init the connection - string dbPath = string.Format(dbPathFormat, PlacesPath); - var dbConnection = new SQLiteConnection(dbPath); - - // Open connection to the database file and execute the query - dbConnection.Open(); - var reader = new SQLiteCommand(queryAllBookmarks, dbConnection).ExecuteReader(); - - // return results in List format - return reader.Select(x => new Bookmark() - { - Name = (x["title"] is DBNull) ? string.Empty : x["title"].ToString(), - Url = x["url"].ToString() - }).ToList(); - } - - /// - /// Path to places.sqlite - /// - private string PlacesPath - { - get - { - var profileFolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Mozilla\Firefox"); - var profileIni = Path.Combine(profileFolderPath, @"profiles.ini"); - - if (!File.Exists(profileIni)) - return string.Empty; - - // get firefox default profile directory from profiles.ini - string ini; - using (var sReader = new StreamReader(profileIni)) { - ini = sReader.ReadToEnd(); - } - var lines = ini.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList(); - - var index = lines.IndexOf("Default=1"); - if (index > 3) { - var relative = lines[index - 2].Split('=')[1]; - var profiePath = lines[index - 1].Split('=')[1]; - return relative == "0" - ? profiePath + @"\places.sqlite" - : Path.Combine(profileFolderPath, profiePath) + @"\places.sqlite"; - } - return string.Empty; - } - } - } - - public static class Extensions - { - public static IEnumerable Select(this SQLiteDataReader reader, Func projection) - { - while (reader.Read()) - { - yield return projection(reader); - } - } - } -} diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Images/bookmark.png b/Plugins/Wox.Plugin.BrowserBookmark/Images/bookmark.png deleted file mode 100644 index b8aee3564e..0000000000 Binary files a/Plugins/Wox.Plugin.BrowserBookmark/Images/bookmark.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs b/Plugins/Wox.Plugin.BrowserBookmark/Main.cs deleted file mode 100644 index 9bf4c885b3..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/Main.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Wox.Infrastructure; - -namespace Wox.Plugin.BrowserBookmark -{ - public class Main : IPlugin - { - private PluginInitContext context; - - // TODO: periodically refresh the Cache? - private List cachedBookmarks = new List(); - - public void Init(PluginInitContext context) - { - this.context = context; - - // Cache all bookmarks - var chromeBookmarks = new ChromeBookmarks(); - var mozBookmarks = new FirefoxBookmarks(); - - //TODO: Let the user select which browser's bookmarks are displayed - // Add Firefox bookmarks - cachedBookmarks.AddRange(mozBookmarks.GetBookmarks()); - // Add Chrome bookmarks - cachedBookmarks.AddRange(chromeBookmarks.GetBookmarks()); - - cachedBookmarks = cachedBookmarks.Distinct().ToList(); - } - - public List Query(Query query) - { - string param = query.GetAllRemainingParameter().TrimStart(); - - // Should top results be returned? (true if no search parameters have been passed) - var topResults = string.IsNullOrEmpty(param); - - var returnList = cachedBookmarks; - - if (!topResults) - { - // Since we mixed chrome and firefox bookmarks, we should order them again - var fuzzyMatcher = FuzzyMatcher.Create(param); - returnList = cachedBookmarks.Where(o => MatchProgram(o, fuzzyMatcher)).ToList(); - returnList = returnList.OrderByDescending(o => o.Score).ToList(); - } - - return returnList.Select(c => new Result() - { - Title = c.Name, - SubTitle = "Bookmark: " + c.Url, - IcoPath = @"Images\bookmark.png", - Score = 5, - Action = (e) => - { - context.API.HideApp(); - context.API.ShellRun(c.Url); - return true; - } - }).ToList(); - } - - private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher) - { - if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) return true; - if ((bookmark.Score = matcher.Evaluate(bookmark.PinyinName).Score) > 0) return true; - if ((bookmark.Score = matcher.Evaluate(bookmark.Url).Score / 10) > 0) return true; - - return false; - } - } -} diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Properties/AssemblyInfo.cs b/Plugins/Wox.Plugin.BrowserBookmark/Properties/AssemblyInfo.cs deleted file mode 100644 index 982c549994..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Wox.Plugin.BrowserBookmark")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Oracle Corporation")] -[assembly: AssemblyProduct("Wox.Plugin.BrowserBookmark")] -[assembly: AssemblyCopyright("Copyright © Oracle Corporation 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7dd2e33e-d029-4661-8f1d-594e82cef077")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj b/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj deleted file mode 100644 index 911e7e0ea2..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/Wox.Plugin.BrowserBookmark.csproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - AnyCPU - {9B130CC5-14FB-41FF-B310-0A95B6894C37} - Library - Properties - Wox.Plugin.BrowserBookmark - Wox.Plugin.BrowserBookmark - v3.5 - 512 - ..\..\ - true - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.BrowserBookmark\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.BrowserBookmark\ - TRACE - prompt - 4 - - - - - - - - False - ..\..\packages\System.Data.SQLite.Core.1.0.93.0\lib\net20\System.Data.SQLite.dll - - - False - ..\..\packages\System.Data.SQLite.Linq.1.0.93.0\lib\net20\System.Data.SQLite.Linq.dll - - - - - - - - - - - - - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - - - PreserveNewest - - - - - Always - - - Always - - - Always - - - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/app.config b/Plugins/Wox.Plugin.BrowserBookmark/app.config deleted file mode 100644 index 20859a6cf9..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/app.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/packages.config b/Plugins/Wox.Plugin.BrowserBookmark/packages.config deleted file mode 100644 index de38b1e84b..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.BrowserBookmark/plugin.json b/Plugins/Wox.Plugin.BrowserBookmark/plugin.json deleted file mode 100644 index 7d40e4bfc8..0000000000 --- a/Plugins/Wox.Plugin.BrowserBookmark/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ID":"0ECADE17459B49F587BF81DC3A125110", - "ActionKeyword":"b", - "Name":"Browser Bookmarks", - "Description":"Search your browser bookmarks", - "Author":"qianlifeng, Ioannis G.", - "Version":"1.1", - "Language":"csharp", - "Website":"http://www.getwox.com/plugin", - "ExecuteFileName":"Wox.Plugin.browserBookmark.dll", - "IcoPath":"Images\\bookmark.png" -} diff --git a/Plugins/Wox.Plugin.BrowserBookmark/x64/SQLite.Interop.dll b/Plugins/Wox.Plugin.BrowserBookmark/x64/SQLite.Interop.dll deleted file mode 100644 index 42db39f835..0000000000 Binary files a/Plugins/Wox.Plugin.BrowserBookmark/x64/SQLite.Interop.dll and /dev/null differ diff --git a/Plugins/Wox.Plugin.BrowserBookmark/x86/SQLite.Interop.dll b/Plugins/Wox.Plugin.BrowserBookmark/x86/SQLite.Interop.dll deleted file mode 100644 index dc22f78416..0000000000 Binary files a/Plugins/Wox.Plugin.BrowserBookmark/x86/SQLite.Interop.dll and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/FindFileContextMenuStorage.cs b/Plugins/Wox.Plugin.FindFile/FindFileContextMenuStorage.cs deleted file mode 100644 index 7bb3b61a7f..0000000000 --- a/Plugins/Wox.Plugin.FindFile/FindFileContextMenuStorage.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Newtonsoft.Json; -using Wox.Infrastructure.Storage; - -namespace Wox.Plugin.FindFile -{ - public class FindFileContextMenuStorage : BaseStorage - { - [JsonProperty] - public List ContextMenus = new List(); - - protected override string ConfigName - { - get { return "FindFileContextMenu"; } - } - - protected override FindFileContextMenuStorage LoadDefaultConfig() - { - ContextMenus = new List() - { - new ContextMenu() - { - Name = "Open Containing Folder", - Command = "explorer.exe", - Argument = " /select \"{path}\"" - } - }; - return this; - } - } - - public class ContextMenu - { - [JsonProperty] - public string Name { get; set; } - - [JsonProperty] - public string Command { get; set; } - - [JsonProperty] - public string Argument { get; set; } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/Images/file.png b/Plugins/Wox.Plugin.FindFile/Images/file.png deleted file mode 100644 index 2913d69623..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/file.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/Images/find.png b/Plugins/Wox.Plugin.FindFile/Images/find.png deleted file mode 100644 index f4a7b2a000..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/find.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/Images/folder.png b/Plugins/Wox.Plugin.FindFile/Images/folder.png deleted file mode 100644 index 330cb2e4bf..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/folder.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/Images/list.png b/Plugins/Wox.Plugin.FindFile/Images/list.png deleted file mode 100644 index ab96e07812..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/list.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/Images/open.png b/Plugins/Wox.Plugin.FindFile/Images/open.png deleted file mode 100644 index 6006d12104..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/open.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/Images/warning.png b/Plugins/Wox.Plugin.FindFile/Images/warning.png deleted file mode 100644 index b1b5f0acd3..0000000000 Binary files a/Plugins/Wox.Plugin.FindFile/Images/warning.png and /dev/null differ diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearchRecord.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearchRecord.cs deleted file mode 100644 index cc3a7ba76c..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearchRecord.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Wox.Plugin.FindFile.MFTSearch -{ - public class MFTSearchRecord - { - private USNRecord usn; - - public MFTSearchRecord(USNRecord usn) - { - this.usn = usn; - } - - public string FullPath - { - get { return usn.FullPath; } - } - - public bool IsFolder - { - get { return usn.IsFolder; } - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcher.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcher.cs deleted file mode 100644 index 39198c4d64..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcher.cs +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Thanks to the https://github.com/yiwenshengmei/MyEverything, we can bring MFT search to Wox - * - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Runtime.InteropServices; - -namespace Wox.Plugin.FindFile.MFTSearch -{ - - public class MFTSearcher - { - private static MFTSearcherCache cache = new MFTSearcherCache(); - private static VolumeMonitor monitor = new VolumeMonitor(); - - private static void IndexVolume(string volume) - { - cache.EnsureVolumeExistInHashTable(volume); - EnumerateVolume(volume, cache.VolumeRecords[volume]); - monitor.Monitor(volume,cache); - } - - public static void IndexAllVolumes() - { - foreach (DriveInfo drive in DriveInfo.GetDrives()) - { - IndexVolume(drive.Name.Replace("\\", "")); - } - } - - public static long IndexedFileCount - { - get { return cache.RecordsCount; } - } - - public static List Search(string item) - { - if (string.IsNullOrEmpty(item)) return new List(); - - List found = cache.FindByName(item, 100); - found.ForEach(x => FillPath(x.VolumeName, x, cache)); - return found.ConvertAll(o => new MFTSearchRecord(o)); - } - - private static void AddVolumeRootRecord(string volumeName, Dictionary files) - { - string rightVolumeName = string.Concat("\\\\.\\", volumeName); - rightVolumeName = string.Concat(rightVolumeName, Path.DirectorySeparatorChar); - IntPtr hRoot = PInvokeWin32.CreateFile(rightVolumeName, - 0, - PInvokeWin32.FILE_SHARE_READ | PInvokeWin32.FILE_SHARE_WRITE, - IntPtr.Zero, - PInvokeWin32.OPEN_EXISTING, - PInvokeWin32.FILE_FLAG_BACKUP_SEMANTICS, - IntPtr.Zero); - - if (hRoot.ToInt32() != PInvokeWin32.INVALID_HANDLE_VALUE) - { - PInvokeWin32.BY_HANDLE_FILE_INFORMATION fi = new PInvokeWin32.BY_HANDLE_FILE_INFORMATION(); - bool bRtn = PInvokeWin32.GetFileInformationByHandle(hRoot, out fi); - if (bRtn) - { - UInt64 fileIndexHigh = (UInt64)fi.FileIndexHigh; - UInt64 indexRoot = (fileIndexHigh << 32) | fi.FileIndexLow; - - files.Add(indexRoot, new USNRecord - { - FRN = indexRoot, - Name = volumeName, - ParentFrn = 0, - IsVolumeRoot = true, - IsFolder = true, - VolumeName = volumeName - }); - } - else - { - throw new IOException("GetFileInformationbyHandle() returned invalid handle", - new Win32Exception(Marshal.GetLastWin32Error())); - } - PInvokeWin32.CloseHandle(hRoot); - } - else - { - throw new IOException("Unable to get root frn entry", new Win32Exception(Marshal.GetLastWin32Error())); - } - } - - private static void EnumerateVolume(string volumeName, Dictionary files) - { - IntPtr medBuffer = IntPtr.Zero; - IntPtr pVolume = IntPtr.Zero; - try - { - AddVolumeRootRecord(volumeName, files); - pVolume = GetVolumeJournalHandle(volumeName); - EnableVomuleJournal(pVolume); - - SetupMFTEnumInBuffer(ref medBuffer, pVolume); - EnumerateFiles(volumeName, pVolume, medBuffer, files); - } - catch (Exception e) - { - Console.WriteLine(e.Message, e); - Exception innerException = e.InnerException; - while (innerException != null) - { - Console.WriteLine(innerException.Message, innerException); - innerException = innerException.InnerException; - } - throw new ApplicationException("Error in EnumerateVolume()", e); - } - finally - { - if (pVolume.ToInt32() != PInvokeWin32.INVALID_HANDLE_VALUE) - { - PInvokeWin32.CloseHandle(pVolume); - if (medBuffer != IntPtr.Zero) - { - Marshal.FreeHGlobal(medBuffer); - } - } - } - } - - internal static IntPtr GetVolumeJournalHandle(string volumeName) - { - string vol = string.Concat("\\\\.\\", volumeName); - IntPtr pVolume = PInvokeWin32.CreateFile(vol, - PInvokeWin32.GENERIC_READ | PInvokeWin32.GENERIC_WRITE, - PInvokeWin32.FILE_SHARE_READ | PInvokeWin32.FILE_SHARE_WRITE, - IntPtr.Zero, - PInvokeWin32.OPEN_EXISTING, - 0, - IntPtr.Zero); - if (pVolume.ToInt32() == PInvokeWin32.INVALID_HANDLE_VALUE) - { - throw new IOException(string.Format("CreateFile(\"{0}\") returned invalid handle", volumeName), - new Win32Exception(Marshal.GetLastWin32Error())); - } - else - { - return pVolume; - } - } - unsafe private static void EnableVomuleJournal(IntPtr pVolume) - { - UInt64 MaximumSize = 0x800000; - UInt64 AllocationDelta = 0x100000; - UInt32 cb; - PInvokeWin32.CREATE_USN_JOURNAL_DATA cujd; - cujd.MaximumSize = MaximumSize; - cujd.AllocationDelta = AllocationDelta; - - int sizeCujd = Marshal.SizeOf(cujd); - IntPtr cujdBuffer = Marshal.AllocHGlobal(sizeCujd); - PInvokeWin32.ZeroMemory(cujdBuffer, sizeCujd); - Marshal.StructureToPtr(cujd, cujdBuffer, true); - - bool fOk = PInvokeWin32.DeviceIoControl(pVolume, PInvokeWin32.FSCTL_CREATE_USN_JOURNAL, - cujdBuffer, sizeCujd, IntPtr.Zero, 0, out cb, IntPtr.Zero); - if (!fOk) - { - throw new IOException("DeviceIoControl() returned false", new Win32Exception(Marshal.GetLastWin32Error())); - } - } - unsafe internal static bool QueryUSNJournal(IntPtr pVolume, out PInvokeWin32.USN_JOURNAL_DATA ujd, out uint bytesReturned) - { - bool bOK = PInvokeWin32.DeviceIoControl( - pVolume, PInvokeWin32.FSCTL_QUERY_USN_JOURNAL, - IntPtr.Zero, - 0, - out ujd, - sizeof(PInvokeWin32.USN_JOURNAL_DATA), - out bytesReturned, - IntPtr.Zero - ); - return bOK; - } - unsafe private static void SetupMFTEnumInBuffer(ref IntPtr medBuffer, IntPtr pVolume) - { - uint bytesReturned = 0; - PInvokeWin32.USN_JOURNAL_DATA ujd = new PInvokeWin32.USN_JOURNAL_DATA(); - - bool bOk = QueryUSNJournal(pVolume, out ujd, out bytesReturned); - if (bOk) - { - PInvokeWin32.MFT_ENUM_DATA med; - med.StartFileReferenceNumber = 0; - med.LowUsn = 0; - med.HighUsn = ujd.NextUsn; - int sizeMftEnumData = Marshal.SizeOf(med); - medBuffer = Marshal.AllocHGlobal(sizeMftEnumData); - PInvokeWin32.ZeroMemory(medBuffer, sizeMftEnumData); - Marshal.StructureToPtr(med, medBuffer, true); - } - else - { - throw new IOException("DeviceIoControl() returned false", new Win32Exception(Marshal.GetLastWin32Error())); - } - } - - unsafe private static void EnumerateFiles(string volumeName, IntPtr pVolume, IntPtr medBuffer, Dictionary files) - { - IntPtr pData = Marshal.AllocHGlobal(sizeof(UInt64) + 0x10000); - PInvokeWin32.ZeroMemory(pData, sizeof(UInt64) + 0x10000); - uint outBytesReturned = 0; - - while (false != PInvokeWin32.DeviceIoControl(pVolume, PInvokeWin32.FSCTL_ENUM_USN_DATA, medBuffer, - sizeof(PInvokeWin32.MFT_ENUM_DATA), pData, sizeof(UInt64) + 0x10000, out outBytesReturned, - IntPtr.Zero)) - { - IntPtr pUsnRecord = new IntPtr(pData.ToInt32() + sizeof(Int64)); - while (outBytesReturned > 60) - { - PInvokeWin32.USN_RECORD usn = new PInvokeWin32.USN_RECORD(pUsnRecord); - - files.Add(usn.FRN, new USNRecord - { - Name = usn.FileName, - ParentFrn = usn.ParentFRN, - FRN = usn.FRN, - IsFolder = usn.IsFolder, - VolumeName = volumeName - }); - - pUsnRecord = new IntPtr(pUsnRecord.ToInt32() + usn.RecordLength); - outBytesReturned -= usn.RecordLength; - } - Marshal.WriteInt64(medBuffer, Marshal.ReadInt64(pData, 0)); - } - Marshal.FreeHGlobal(pData); - } - - internal static void FillPath(string volume, USNRecord record, MFTSearcherCache db) - { - if (record == null) return; - var fdSource = db.GetVolumeRecords(volume); - string fullpath = record.Name; - FindRecordPath(record, ref fullpath, fdSource); - record.FullPath = fullpath; - } - - private static void FindRecordPath(USNRecord curRecord, ref string fullpath, Dictionary fdSource) - { - if (curRecord.IsVolumeRoot) return; - USNRecord nextRecord = null; - if (!fdSource.TryGetValue(curRecord.ParentFrn, out nextRecord)) - return; - fullpath = string.Format("{0}{1}{2}", nextRecord.Name, Path.DirectorySeparatorChar, fullpath); - FindRecordPath(nextRecord, ref fullpath, fdSource); - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcherCache.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcherCache.cs deleted file mode 100644 index e60e558d4d..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/MFTSearcherCache.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Wox.Plugin.FindFile.MFTSearch -{ - internal class MFTSearcherCache - { - public Dictionary> VolumeRecords = new Dictionary>(); - public static object locker = new object(); - - public MFTSearcherCache() { } - - public bool ContainsVolume(string volume) - { - return VolumeRecords.ContainsKey(volume); - } - - public void AddRecord(string volume, List r) - { - EnsureVolumeExistInHashTable(volume); - r.ForEach(x => VolumeRecords[volume].Add(x.FRN, x)); - } - - public void AddRecord(string volume, USNRecord record) - { - EnsureVolumeExistInHashTable(volume); - if (!VolumeRecords[volume].ContainsKey(record.FRN)) - { - lock (locker) - { - VolumeRecords[volume].Add(record.FRN, record); - } - } - } - - public void EnsureVolumeExistInHashTable(string volume) - { - if (!VolumeRecords.ContainsKey(volume)) - VolumeRecords.Add(volume, new Dictionary()); - } - - public bool DeleteRecord(string volume, ulong frn) - { - bool result = false; - result = DeleteRecordHashTableItem(VolumeRecords, volume, frn); - return result; - } - - private bool DeleteRecordHashTableItem(Dictionary> hashtable, string volume, ulong frn) - { - if (hashtable.ContainsKey(volume) && hashtable[volume].ContainsKey(frn)) - { - lock (locker) - { - hashtable[volume].Remove(frn); - } - return true; - } - else - { - return false; - } - } - - public void UpdateRecord(string volume, USNRecord record) - { - RealUpdateRecord(volume, VolumeRecords, record); - } - - private bool RealUpdateRecord(string volume, Dictionary> source, USNRecord record) - { - if (source.ContainsKey(volume) && source[volume].ContainsKey(record.FRN)) - { - lock (locker) - { - source[volume][record.FRN] = record; - } - return true; - } - else - { - return false; - } - } - - public List FindByName(string filename, long maxResult = -1) - { - List result = new List(); - lock (locker) - { - foreach (Dictionary dictionary in VolumeRecords.Values) - { - foreach (var usnRecord in dictionary) - { - if (usnRecord.Value.Name.IndexOf(filename, StringComparison.OrdinalIgnoreCase) >= 0) - { - result.Add(usnRecord.Value); - if (maxResult > 0 && result.Count() >= maxResult) break; - } - if (maxResult > 0 && result.Count() >= maxResult) break; - } - } - } - return result; - } - - public USNRecord FindByFrn(string volume, ulong frn) - { - if ((!VolumeRecords.ContainsKey(volume))) - throw new Exception(string.Format("DB not contain the volume: {0}", volume)); - USNRecord result = null; - VolumeRecords[volume].TryGetValue(frn, out result); - return result; - } - - public long RecordsCount - { - get { return VolumeRecords.Sum(x => x.Value.Count); } - } - - public Dictionary GetVolumeRecords(string volume) - { - Dictionary result = null; - VolumeRecords.TryGetValue(volume, out result); - return result; - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/PInvokeWin32.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/PInvokeWin32.cs deleted file mode 100644 index dd5a7735d9..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/PInvokeWin32.cs +++ /dev/null @@ -1,165 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace Wox.Plugin.FindFile.MFTSearch { - public class PInvokeWin32 - { - - public const UInt32 GENERIC_READ = 0x80000000; - public const UInt32 GENERIC_WRITE = 0x40000000; - public const UInt32 FILE_SHARE_READ = 0x00000001; - public const UInt32 FILE_SHARE_WRITE = 0x00000002; - public const UInt32 FILE_ATTRIBUTE_DIRECTORY = 0x00000010; - public const UInt32 OPEN_EXISTING = 3; - public const UInt32 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000; - public const Int32 INVALID_HANDLE_VALUE = -1; - public const UInt32 FSCTL_QUERY_USN_JOURNAL = 0x000900f4; - public const UInt32 FSCTL_ENUM_USN_DATA = 0x000900b3; - public const UInt32 FSCTL_CREATE_USN_JOURNAL = 0x000900e7; - public const UInt32 FSCTL_READ_USN_JOURNAL = 0x000900bb; - - - - [DllImport("kernel32.dll", SetLastError = true)] - public static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, - uint dwShareMode, IntPtr lpSecurityAttributes, - uint dwCreationDisposition, uint dwFlagsAndAttributes, - IntPtr hTemplateFile); - - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetFileInformationByHandle(IntPtr hFile, - out BY_HANDLE_FILE_INFORMATION lpFileInformation); - - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CloseHandle(IntPtr hObject); - - [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeviceIoControl(IntPtr hDevice, - UInt32 dwIoControlCode, - IntPtr lpInBuffer, Int32 nInBufferSize, - out USN_JOURNAL_DATA lpOutBuffer, Int32 nOutBufferSize, - out uint lpBytesReturned, IntPtr lpOverlapped); - - [DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true, CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool DeviceIoControl(IntPtr hDevice, - UInt32 dwIoControlCode, - IntPtr lpInBuffer, Int32 nInBufferSize, - IntPtr lpOutBuffer, Int32 nOutBufferSize, - out uint lpBytesReturned, IntPtr lpOverlapped); - - [DllImport("kernel32.dll")] - public static extern void ZeroMemory(IntPtr ptr, Int32 size); - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct BY_HANDLE_FILE_INFORMATION { - public uint FileAttributes; - public FILETIME CreationTime; - public FILETIME LastAccessTime; - public FILETIME LastWriteTime; - public uint VolumeSerialNumber; - public uint FileSizeHigh; - public uint FileSizeLow; - public uint NumberOfLinks; - public uint FileIndexHigh; - public uint FileIndexLow; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct FILETIME { - public uint DateTimeLow; - public uint DateTimeHigh; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct USN_JOURNAL_DATA { - public UInt64 UsnJournalID; - public Int64 FirstUsn; - public Int64 NextUsn; - public Int64 LowestValidUsn; - public Int64 MaxUsn; - public UInt64 MaximumSize; - public UInt64 AllocationDelta; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct MFT_ENUM_DATA { - public UInt64 StartFileReferenceNumber; - public Int64 LowUsn; - public Int64 HighUsn; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct CREATE_USN_JOURNAL_DATA { - public UInt64 MaximumSize; - public UInt64 AllocationDelta; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct READ_USN_JOURNAL_DATA { - public Int64 StartUsn; - public UInt32 ReasonMask; - public UInt32 ReturnOnlyOnClose; - public UInt64 Timeout; - public UInt64 BytesToWaitFor; - public UInt64 UsnJournalID; - } - - public class USN_RECORD { - public UInt32 RecordLength; - public UInt16 MajorVersion; - public UInt16 MinorVersion; - public UInt64 FRN; // 8 - public UInt64 ParentFRN; // 16 - public Int64 Usn; // Need be care - public UInt64 TimeStamp; // Need Be care - public UInt32 Reason; - public UInt32 SourceInfo; - public UInt32 SecurityId; - public UInt32 FileAttributes; // 52 - public UInt16 FileNameLength; - public UInt16 FileNameOffset; - public string FileName = string.Empty; - - private const int RecordLength_OFFSET = 0; - private const int MajorVersion_OFFSET = 4; - private const int MinorVersion_OFFSET = 6; - private const int FileReferenceNumber_OFFSET = 8; - private const int ParentFileReferenceNumber_OFFSET = 16; - private const int Usn_OFFSET = 24; - private const int TimeStamp_OFFSET = 32; - private const int Reason_OFFSET = 40; - private const int SourceInfo_OFFSET = 44; - private const int SecurityId_OFFSET = 48; - private const int FileAttributes_OFFSET = 52; - private const int FileNameLength_OFFSET = 56; - private const int FileNameOffset_OFFSET = 58; - private const int FileName_OFFSET = 60; - - public USN_RECORD(IntPtr p) { - this.RecordLength = (UInt32)Marshal.ReadInt32(p, RecordLength_OFFSET); - this.MajorVersion = (UInt16)Marshal.ReadInt16(p, MajorVersion_OFFSET); - this.MinorVersion = (UInt16)Marshal.ReadInt16(p, MinorVersion_OFFSET); - this.FRN = (UInt64)Marshal.ReadInt64(p, FileReferenceNumber_OFFSET); - this.ParentFRN = (UInt64)Marshal.ReadInt64(p, ParentFileReferenceNumber_OFFSET); - this.Usn = Marshal.ReadInt64(p, Usn_OFFSET); - this.TimeStamp = (UInt64)Marshal.ReadInt64(p, TimeStamp_OFFSET); - this.Reason = (UInt32)Marshal.ReadInt32(p, Reason_OFFSET); - this.SourceInfo = (UInt32)Marshal.ReadInt32(p, SourceInfo_OFFSET); - this.SecurityId = (UInt32)Marshal.ReadInt32(p, SecurityId_OFFSET); - this.FileAttributes = (UInt32)Marshal.ReadInt32(p, FileAttributes_OFFSET); - this.FileNameLength = (UInt16)Marshal.ReadInt16(p, FileNameLength_OFFSET); - this.FileNameOffset = (UInt16)Marshal.ReadInt16(p, FileNameOffset_OFFSET); - - this.FileName = Marshal.PtrToStringUni(new IntPtr(p.ToInt32() + this.FileNameOffset), this.FileNameLength / sizeof(char)); - } - - public bool IsFolder { - get { return 0 != (FileAttributes & PInvokeWin32.FILE_ATTRIBUTE_DIRECTORY); } - } - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/USNChangeReason.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/USNChangeReason.cs deleted file mode 100644 index c550208eb0..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/USNChangeReason.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Wox.Plugin.FindFile.MFTSearch -{ - internal class USNChangeReason - { - public static Dictionary USN_REASONS = new Dictionary { - {"USN_REASON_DATA_OVERWRITE", 0x00000001}, - {"USN_REASON_DATA_EXTEND", 0x00000002}, - {"USN_REASON_DATA_TRUNCATION", 0x00000004}, - {"USN_REASON_NAMED_DATA_OVERWRITE", 0x00000010}, - {"USN_REASON_NAMED_DATA_EXTEND", 0x00000020}, - {"USN_REASON_NAMED_DATA_TRUNCATION", 0x00000040}, - {"USN_REASON_FILE_CREATE", 0x00000100}, - {"USN_REASON_FILE_DELETE", 0x00000200}, - {"USN_REASON_EA_CHANGE", 0x00000400}, - {"USN_REASON_SECURITY_CHANGE", 0x00000800}, - {"USN_REASON_RENAME_OLD_NAME", 0x00001000}, - {"USN_REASON_RENAME_NEW_NAME", 0x00002000}, - {"USN_REASON_INDEXABLE_CHANGE", 0x00004000}, - {"USN_REASON_BASIC_INFO_CHANGE", 0x00008000}, - {"USN_REASON_HARD_LINK_CHANGE", 0x00010000}, - {"USN_REASON_COMPRESSION_CHANGE", 0x00020000}, - {"USN_REASON_ENCRYPTION_CHANGE", 0x00040000}, - {"USN_REASON_OBJECT_ID_CHANGE", 0x00080000}, - {"USN_REASON_REPARSE_POINT_CHANGE", 0x00100000}, - {"USN_REASON_STREAM_CHANGE", 0x00200000}, - {"USN_REASON_TRANSACTED_CHANGE", 0x00400000}, - {"USN_REASON_CLOSE", 0x80000000} - }; - - public static string ReasonPrettyFormat(UInt32 rsn) - { - StringBuilder sb = new StringBuilder(); - sb.Append("["); - foreach (var rsnPair in USN_REASONS) - { - if ((rsnPair.Value & rsn) != 0) - sb.Append(rsnPair.Key + " "); - } - sb.Append("]"); - return sb.ToString(); - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/USNRecord.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/USNRecord.cs deleted file mode 100644 index 8fbad7b231..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/USNRecord.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -namespace Wox.Plugin.FindFile.MFTSearch -{ - public class USNRecord - { - - public string Name { get; set; } - public ulong FRN { get; set; } - public UInt64 ParentFrn { get; set; } - public string FullPath { get; set; } - public bool IsVolumeRoot { get; set; } - public bool IsFolder { get; set; } - public string VolumeName { get; set; } - - public override string ToString() - { - return string.IsNullOrEmpty(FullPath) ? Name : FullPath; - } - - public static USNRecord ParseUSN(string volume, PInvokeWin32.USN_RECORD usn) - { - return new USNRecord - { - FRN = usn.FRN, - Name = usn.FileName, - ParentFrn = usn.ParentFRN, - IsFolder = usn.IsFolder, - VolumeName = volume - }; - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/MFTSearch/VolumeMonitor.cs b/Plugins/Wox.Plugin.FindFile/MFTSearch/VolumeMonitor.cs deleted file mode 100644 index 6048bacf75..0000000000 --- a/Plugins/Wox.Plugin.FindFile/MFTSearch/VolumeMonitor.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Threading; - -namespace Wox.Plugin.FindFile.MFTSearch -{ - internal class VolumeMonitor - { - public Action RecordAddedEvent; - public Action RecordDeletedEvent; - public Action RecordRenameEvent; - - public void Monitor(List volumes, MFTSearcherCache db) - { - foreach (var volume in volumes) - { - Monitor(volume, db); - } - } - - public void Monitor(string volume, MFTSearcherCache db) - { - if (string.IsNullOrEmpty(volume)) throw new InvalidOperationException("Volume cant't be null or empty string."); - if (!db.ContainsVolume(volume)) throw new InvalidOperationException(string.Format("Volume {0} must be scaned first.")); - - ThreadPool.QueueUserWorkItem(o => MonitorThread(volume, db)); - } - - private PInvokeWin32.READ_USN_JOURNAL_DATA SetupInputData4JournalRead(string volume, uint reason) - { - IntPtr pMonitorVolume = MFTSearcher.GetVolumeJournalHandle(volume); - uint bytesReturned = 0; - PInvokeWin32.USN_JOURNAL_DATA ujd = new PInvokeWin32.USN_JOURNAL_DATA(); - MFTSearcher.QueryUSNJournal(pMonitorVolume, out ujd, out bytesReturned); - - // 构建输入参数 - PInvokeWin32.READ_USN_JOURNAL_DATA rujd = new PInvokeWin32.READ_USN_JOURNAL_DATA(); - rujd.StartUsn = ujd.NextUsn; - rujd.ReasonMask = reason; - rujd.ReturnOnlyOnClose = 1; - rujd.Timeout = 0; - rujd.BytesToWaitFor = 1; - rujd.UsnJournalID = ujd.UsnJournalID; - - return rujd; - } - - private void MonitorThread(string volume, MFTSearcherCache db) - { - IntPtr pbuffer = Marshal.AllocHGlobal(0x1000); - PInvokeWin32.READ_USN_JOURNAL_DATA rujd = SetupInputData4JournalRead(volume, 0xFFFFFFFF); - UInt32 cbRead; - IntPtr prujd; - - while (true) - { - prujd = Marshal.AllocHGlobal(Marshal.SizeOf(rujd)); - PInvokeWin32.ZeroMemory(prujd, Marshal.SizeOf(rujd)); - Marshal.StructureToPtr(rujd, prujd, true); - - IntPtr pVolume = MFTSearcher.GetVolumeJournalHandle(volume); - - bool fok = PInvokeWin32.DeviceIoControl(pVolume, - PInvokeWin32.FSCTL_READ_USN_JOURNAL, - prujd, Marshal.SizeOf(typeof(PInvokeWin32.READ_USN_JOURNAL_DATA)), - pbuffer, 0x1000, out cbRead, IntPtr.Zero); - - IntPtr pRealData = new IntPtr(pbuffer.ToInt32() + Marshal.SizeOf(typeof(Int64))); - uint offset = 0; - - if (fok) - { - while (offset + Marshal.SizeOf(typeof(Int64)) < cbRead) - { - PInvokeWin32.USN_RECORD usn = new PInvokeWin32.USN_RECORD(new IntPtr(pRealData.ToInt32() + (int)offset)); - ProcessUSN(usn, volume, db); - offset += usn.RecordLength; - } - } - - Marshal.FreeHGlobal(prujd); - rujd.StartUsn = Marshal.ReadInt64(pbuffer); - } - } - - private void ProcessUSN(PInvokeWin32.USN_RECORD usn, string volume, MFTSearcherCache db) - { - if (MaskEqual(usn.Reason, USNChangeReason.USN_REASONS["USN_REASON_RENAME_NEW_NAME"])) - ProcessRenameNewName(usn, volume, db); - if ((usn.Reason & USNChangeReason.USN_REASONS["USN_REASON_FILE_CREATE"]) != 0) - ProcessFileCreate(usn, volume, db); - if (MaskEqual(usn.Reason, USNChangeReason.USN_REASONS["USN_REASON_FILE_DELETE"])) - ProcessFileDelete(usn, volume, db); - } - - private void ProcessFileDelete(PInvokeWin32.USN_RECORD usn, string volume, MFTSearcherCache db) - { - var cached = db.FindByFrn(volume, usn.FRN); - if (cached != null) - { - MFTSearcher.FillPath(volume, cached, db); - var deleteok = db.DeleteRecord(volume, usn.FRN); - Debug.WriteLine(string.Format(">>>> DeleteFIle {0} {1}.", cached.FullPath, deleteok ? "successful" : "fail")); - if (RecordDeletedEvent != null) - RecordDeletedEvent(cached); - } - } - - private void ProcessRenameNewName(PInvokeWin32.USN_RECORD usn, string volume, MFTSearcherCache db) - { - USNRecord newRecord = USNRecord.ParseUSN(volume, usn); - db.UpdateRecord(volume, newRecord); - - var oldRecord = db.FindByFrn(volume, usn.FRN); - if (oldRecord != null) - { - Debug.WriteLine(string.Format(">>>> RenameFile {0} to {1}", oldRecord.FullPath, newRecord.FullPath)); - if (RecordRenameEvent != null) RecordRenameEvent(oldRecord, newRecord); - } - } - - private void ProcessFileCreate(PInvokeWin32.USN_RECORD usn, string volume, MFTSearcherCache db) - { - USNRecord record = USNRecord.ParseUSN(volume, usn); - db.AddRecord(volume, record); - Debug.WriteLine(string.Format(">>>> NewFile: {0}", record.FullPath)); - if (RecordAddedEvent != null) - RecordAddedEvent(record); - } - - - private bool MaskEqual(uint target, uint compare) - { - return (target & compare) != 0; - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/Main.cs b/Plugins/Wox.Plugin.FindFile/Main.cs deleted file mode 100644 index 917712b033..0000000000 --- a/Plugins/Wox.Plugin.FindFile/Main.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using System.Windows.Controls; -using Wox.Infrastructure; -using Wox.Plugin.FindFile.MFTSearch; - -namespace Wox.Plugin.FindFile -{ - public class Main : IPlugin, ISettingProvider - { - private PluginInitContext context; - private bool initial = false; - - public List Query(Query query) - { - if (!initial) - { - return new List() - { - new Result("Wox is indexing your files, please try later.","Images/warning.png") - }; - } - - string q = query.GetAllRemainingParameter(); - return MFTSearcher.Search(q).Take(100).Select(t => ConvertMFTSearch(t, q)).ToList(); - } - - public void Init(PluginInitContext context) - { - this.context = context; - var searchtimestart = DateTime.Now; - MFTSearcher.IndexAllVolumes(); - initial = true; - var searchtimeend = DateTime.Now; - Debug.WriteLine(string.Format("{0} file, indexed, {1}ms has spent.", MFTSearcher.IndexedFileCount, searchtimeend.Subtract(searchtimestart).TotalMilliseconds)); - } - - private Result ConvertMFTSearch(MFTSearchRecord record, string query) - { - string icoPath = "Images/file.png"; - if (record.IsFolder) - { - icoPath = "Images/folder.png"; - } - - string name = Path.GetFileName(record.FullPath); - FuzzyMatcher matcher = FuzzyMatcher.Create(query); - return new Result() - { - Title = name, - Score = matcher.Evaluate(name).Score, - SubTitle = record.FullPath, - IcoPath = icoPath, - Action = _ => - { - try - { - Process.Start(record.FullPath); - } - catch - { - context.API.ShowMsg("Can't open " + record.FullPath, string.Empty, string.Empty); - return false; - } - return true; - }, - ContextMenu = GetContextMenu(record) - }; - } - - private List GetContextMenu(MFTSearchRecord record) - { - List contextMenus = new List(); - - if (!record.IsFolder) - { - foreach (ContextMenu contextMenu in FindFileContextMenuStorage.Instance.ContextMenus) - { - contextMenus.Add(new Result() - { - Title = contextMenu.Name, - Action = _ => - { - string argument = contextMenu.Argument.Replace("{path}", record.FullPath); - try - { - Process.Start(contextMenu.Command,argument); - } - catch - { - context.API.ShowMsg("Can't start " + record.FullPath, string.Empty, string.Empty); - return false; - } - return true; - }, - IcoPath = "Images/list.png" - }); - } - } - - return contextMenus; - } - - public Control CreateSettingPanel() - { - return new Setting(); - } - } -} diff --git a/Plugins/Wox.Plugin.FindFile/Properties/AssemblyInfo.cs b/Plugins/Wox.Plugin.FindFile/Properties/AssemblyInfo.cs deleted file mode 100644 index 1484395d76..0000000000 --- a/Plugins/Wox.Plugin.FindFile/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的常规信息通过以下 -// 特性集控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("Wox.Plugin.FindFile")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Wox.Plugin.FindFile")] -[assembly: AssemblyCopyright("Copyright © 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 使此程序集中的类型 -// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, -// 则将该类型上的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("93b857b4-07a4-4ac1-a3ee-d038ace03ce9")] - -// 程序集的版本信息由下面四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, -// 方法是按如下所示使用“*”: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj b/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj deleted file mode 100644 index 0324d2b966..0000000000 --- a/Plugins/Wox.Plugin.FindFile/Wox.Plugin.FindFile.csproj +++ /dev/null @@ -1,132 +0,0 @@ - - - - - Debug - AnyCPU - {84EA88B4-71F2-4A3D-9771-D7B0244C0D81} - Library - Properties - Wox.Plugin.FindFile - Wox.Plugin.FindFile - v3.5 - 512 - - ..\..\ - true - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.FindFile\ - DEBUG;TRACE - prompt - 4 - true - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.FindFile\ - TRACE - prompt - 4 - true - - - - False - ..\..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - - - False - ..\..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll - - - - - - - ..\..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Input.Toolkit.dll - - - ..\..\packages\WPFToolkit.3.5.50211.1\lib\System.Windows.Controls.Layout.Toolkit.dll - - - - - - - - - ..\..\packages\WPFToolkit.3.5.50211.1\lib\WPFToolkit.dll - - - - - - - - - - - - - - - Setting.xaml - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - Always - - - Always - - - Always - - - Always - - - Always - - - Always - - - - - - PreserveNewest - - - - - Designer - MSBuild:Compile - - - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.FindFile/packages.config b/Plugins/Wox.Plugin.FindFile/packages.config deleted file mode 100644 index 30b7b9cf8c..0000000000 --- a/Plugins/Wox.Plugin.FindFile/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.FindFile/plugin.json b/Plugins/Wox.Plugin.FindFile/plugin.json deleted file mode 100644 index ed9c9f3930..0000000000 --- a/Plugins/Wox.Plugin.FindFile/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ID":"64EDFA42642446E5BBFF2546EE4549BB", - "ActionKeyword":"f", - "Name":"Find Files and Folders", - "Description":"Search all your files and folders in your disk", - "Author":"qianlifeng", - "Version":"1.0", - "Language":"csharp", - "Website":"http://www.getwox.com/plugin", - "ExecuteFileName":"Wox.Plugin.FindFile.dll", - "IcoPath":"Images\\find.png" -} diff --git a/Plugins/Wox.Plugin.FindFile/setting.xaml b/Plugins/Wox.Plugin.FindFile/setting.xaml deleted file mode 100644 index a0218954d8..0000000000 --- a/Plugins/Wox.Plugin.FindFile/setting.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/Plugins/Wox.Plugin.FindFile/setting.xaml.cs b/Plugins/Wox.Plugin.FindFile/setting.xaml.cs deleted file mode 100644 index 1df74a4291..0000000000 --- a/Plugins/Wox.Plugin.FindFile/setting.xaml.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Wox.Plugin.FindFile -{ - public partial class Setting : UserControl - { - public Setting() - { - InitializeComponent(); - menuGrid.ItemsSource = FindFileContextMenuStorage.Instance.ContextMenus; - menuGrid.CurrentCellChanged += menuGrid_CurrentCellChanged; - } - - void menuGrid_CurrentCellChanged(object sender, EventArgs e) - { - FindFileContextMenuStorage.Instance.Save(); - } - } -} diff --git a/Plugins/Wox.Plugin.HackerNews/Images/app.ico b/Plugins/Wox.Plugin.HackerNews/Images/app.ico deleted file mode 100644 index a415c1eaf1..0000000000 Binary files a/Plugins/Wox.Plugin.HackerNews/Images/app.ico and /dev/null differ diff --git a/Plugins/Wox.Plugin.HackerNews/main.py b/Plugins/Wox.Plugin.HackerNews/main.py deleted file mode 100644 index e56bd7cd28..0000000000 --- a/Plugins/Wox.Plugin.HackerNews/main.py +++ /dev/null @@ -1,34 +0,0 @@ -#encoding=utf8 - -import requests -from bs4 import BeautifulSoup -import webbrowser -from wox import Wox,WoxAPI - -class HackerNews(Wox): - - def query(self,key): - proxies = {} - if self.proxy and self.proxy.get("enabled") and self.proxy.get("server"): - proxies = { - "http": "http://{}:{}".format(self.proxy.get("server"),self.proxy.get("port")), - "http": "https://{}:{}".format(self.proxy.get("server"),self.proxy.get("port")) - } - #self.debug(proxies) - r = requests.get('https://news.ycombinator.com/',proxies = proxies) - bs = BeautifulSoup(r.text) - results = [] - for i in bs.select(".comhead"): - title = i.previous_sibling.text - url = i.previous_sibling["href"] - results.append({"Title": title ,"IcoPath":"Images/app.ico","JsonRPCAction":{"method": "openUrl","parameters":[url],"dontHideAfterAction":True}}) - - return results - - def openUrl(self,url): - webbrowser.open(url) - #todo:doesn't work when move this line up - WoxAPI.change_query(url) - -if __name__ == "__main__": - HackerNews() diff --git a/Plugins/Wox.Plugin.HackerNews/plugin.json b/Plugins/Wox.Plugin.HackerNews/plugin.json deleted file mode 100644 index d3c608d32b..0000000000 --- a/Plugins/Wox.Plugin.HackerNews/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ID":"D2D2C23B084D411DB66FE0C79D6C1B7H", - "ActionKeyword":"hn", - "Name":"Hacker News", - "Description":"Hacker News@https://news.ycombinator.com", - "Author":"qianlifeng", - "Version":"1.0", - "Language":"python", - "Website":"http://www.getwox.com", - "IcoPath":"Images\\app.ico", - "ExecuteFileName":"main.py" -} diff --git a/Plugins/Wox.Plugin.HackerNews/run.bat b/Plugins/Wox.Plugin.HackerNews/run.bat deleted file mode 100644 index c5355024bb..0000000000 --- a/Plugins/Wox.Plugin.HackerNews/run.bat +++ /dev/null @@ -1,2 +0,0 @@ -..\..\PythonHome\python.exe main.py "{\"jsonrpc\": \"2.0\", \"method\": \"query\", \"params\": \"l\", \"id\": 1} -REM ..\..\PythonHome\python.exe main.py "{\"method\":\"openUrl\",\"parameters\":[\"https://blog.pinboard.in/2014/07/pinboard_turns_five/\",2]}"