From c83577cb81267f7b1239a6fc723e0ea1120912e5 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Thu, 21 Apr 2016 21:04:33 +0100 Subject: [PATCH] Remove unused code --- .../Wox.Plugin.QueryHistory/HistoryItem.cs | 53 ---- .../Images/history.png | Bin 4219 -> 0 bytes .../Properties/AssemblyInfo.cs | 36 --- .../Wox.Plugin.QueryHistory/QueryHistory.cs | 49 ---- .../QueryHistoryStorage.cs | 83 ------ .../Wox.Plugin.QueryHistory.csproj | 85 ------ .../Wox.Plugin.QueryHistory/packages.config | 4 - Plugins/Wox.Plugin.QueryHistory/plugin.json | 12 - Wox.UpdateFeedGenerator/ConfigStorage.cs | 45 ---- Wox.UpdateFeedGenerator/FileInfoEx.cs | 39 --- .../FileSystemEnumerator.cs | 248 ------------------ Wox.UpdateFeedGenerator/Generator.cs | 179 ------------- Wox.UpdateFeedGenerator/Program.cs | 10 - .../Properties/AssemblyInfo.cs | 5 - Wox.UpdateFeedGenerator/README.md | 1 - .../Wox.UpdateFeedGenerator.csproj | 86 ------ Wox.UpdateFeedGenerator/app.config | 3 - Wox.UpdateFeedGenerator/packages.config | 5 - Wox.sln | 13 +- 19 files changed, 1 insertion(+), 955 deletions(-) delete mode 100644 Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs delete mode 100644 Plugins/Wox.Plugin.QueryHistory/Images/history.png delete mode 100644 Plugins/Wox.Plugin.QueryHistory/Properties/AssemblyInfo.cs delete mode 100644 Plugins/Wox.Plugin.QueryHistory/QueryHistory.cs delete mode 100644 Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs delete mode 100644 Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj delete mode 100644 Plugins/Wox.Plugin.QueryHistory/packages.config delete mode 100644 Plugins/Wox.Plugin.QueryHistory/plugin.json delete mode 100644 Wox.UpdateFeedGenerator/ConfigStorage.cs delete mode 100644 Wox.UpdateFeedGenerator/FileInfoEx.cs delete mode 100644 Wox.UpdateFeedGenerator/FileSystemEnumerator.cs delete mode 100644 Wox.UpdateFeedGenerator/Generator.cs delete mode 100644 Wox.UpdateFeedGenerator/Program.cs delete mode 100644 Wox.UpdateFeedGenerator/Properties/AssemblyInfo.cs delete mode 100644 Wox.UpdateFeedGenerator/README.md delete mode 100644 Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj delete mode 100644 Wox.UpdateFeedGenerator/app.config delete mode 100644 Wox.UpdateFeedGenerator/packages.config diff --git a/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs b/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs deleted file mode 100644 index 0921a95203..0000000000 --- a/Plugins/Wox.Plugin.QueryHistory/HistoryItem.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Wox.Plugin.QueryHistory -{ - public class HistoryItem - { - public string Query { get; set; } - public DateTime ExecutedDateTime { get; set; } - - public string GetTimeAgo() - { - return DateTimeAgo(ExecutedDateTime); - } - - private string DateTimeAgo(DateTime dt) - { - TimeSpan span = DateTime.Now - dt; - if (span.Days > 365) - { - int years = (span.Days / 365); - if (span.Days % 365 != 0) - years += 1; - return String.Format("about {0} {1} ago", - years, years == 1 ? "year" : "years"); - } - if (span.Days > 30) - { - int months = (span.Days / 30); - if (span.Days % 31 != 0) - months += 1; - return String.Format("about {0} {1} ago", - months, months == 1 ? "month" : "months"); - } - if (span.Days > 0) - return String.Format("about {0} {1} ago", - span.Days, span.Days == 1 ? "day" : "days"); - if (span.Hours > 0) - return String.Format("about {0} {1} ago", - span.Hours, span.Hours == 1 ? "hour" : "hours"); - if (span.Minutes > 0) - return String.Format("about {0} {1} ago", - span.Minutes, span.Minutes == 1 ? "minute" : "minutes"); - if (span.Seconds > 5) - return String.Format("about {0} seconds ago", span.Seconds); - if (span.Seconds <= 5) - return "just now"; - return string.Empty; - } - } -} diff --git a/Plugins/Wox.Plugin.QueryHistory/Images/history.png b/Plugins/Wox.Plugin.QueryHistory/Images/history.png deleted file mode 100644 index 6bb070398fdac483d4a9a5d6ce14440334efd927..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4219 zcmV->5QOiEP)QnwUV9PP3!h_+jH7m^T?IESxzJY#$8@!aqF9pC=(-kW)ogaz8& zR(;Y>W54+wpU?OF{l32e{+~a}k6^4C`c(b*;RXP7Nt1p<=#%~@AU^JxplN>70Yv1O5Le3B;q4#G};3I z(sqh4?W|I*T%hIR8IfB&z4*O%rsk)n$^a|?uHX2_CGt@TDDcc903HL-vFrZ(w&~-W z_v`D|9qJtD-x`lZ5YwZGMs(<^4psB4iwgmyzedS{l z2-|rKKyvij9V6*O2kuYr+5Oq>bh?KiQED_$F-=&m(;7+SiH;~FLjsZi4nQmtK`Nd^ zS278W6qL)wV);Mcd8YFETi=*Ic`^&20Z$`g|G4bYJ_NiDPwL$}?!4oM?jwhPW9{CX zAC4vBiIrLv^Q)_p+XLfU_EsGm`BDiD*Y*+p5G7s`MB7nN^V4!1 zR2vOws)pX-kulzz+0t#qmkMXk74RYcaHZ8%pI96~X4{c__VwI%$LG6;hc++QYN%RP z+u{_SmI(IjoZUEmwqahFc3LHjX6}`Q0A4Edg|9tV zsGoRWO2^gE9^1q7YN`o0@6*3&GGM=uLH@HaB;o{K6|=zVPN- zZvzNIZg}1{6AD6Q6hP|H^SSC!@_9fJ6_Qk9<^_#z!w`VR&5Sc!32LOx4V$Sf^ zYxss6Z_o!fjlnPs+p1QX;9Mfe#6-f)FKXr2->M|GZZY((&PdCg04^8=7w8-s9OW)+ z6i=Ky<B*|2Z#{xy$2^e2eN(^a$4>fsBierlqc{o}7zNC?N5Hjl>R zZ2Y!;vF#82>}Gx4RYuLSU^51Q5Yu%eVsVJMtaJM4bLUQf=MCGn>|omwS2WES`lZix z#kXuqK>;8=O%M@M$s{z>Ev-EJ^(SWj{kv}fDEh*Z04UHvApInO{=xh1`h~>khHI;4 z!*etrIHV`}xi9}&k%X}PiNxkxZpK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`?g<1d&#}6 zHX1H1b^#ayuu)5;?lgAo`jkGnwqK3Mp=fRUKhOR&9htR*NcF8j(y{~=7i;FsOfjgq z69I|!SNC9WptBK+Y2~FQlos-kj9(VzNC-&N1Y2BOVkb|$CTg{p089eN0jT)GxU4c4 zCebYJ!t;kwt+Vs?==SaV^|eE5)mR*AB;sZ2D}>BQECwT)gpo|PP3$!4u<8wP%eqVe z%~Kk4AuS6$pUbm}GjE7`{a*k~!L$1hE$)UNiB^SKkn0xZ@-ipJQffzM2L6%rN_j$Z z4yVz8SuT66RDxM9!)=(5jJ4wq!n5lEm!=6ed2W)OKlg2En%@R610e5%4{zz4&j%48 zzjO0SlsGTSQmH6PrKr-;nITD$rp-3d2cZ`2vA?-$yPcEEK#mJ(HXy1M(>;0on3$h` znHc*nfLR}W376RYM)cWy@gaNFhOyceo)g z0LDR#LAoxaX?jv`)CHTEm}D2uy)G-2mqBy}z(sfwCy;#j`nB!(SeJYNG64Dk3<4NX z4C4m1J2S2g4vuI&y=g_$K#Jm-R`akI>^;2gv*Mo}cyXm97ZX^A3PTAM_Hu zO#6{8`TkqitN_vgdI9tS=z*dPDN$pil1L1z9UXm2M`xEBPb6W)q9A}A+m&{sLG^lt z>h)zZ&3SU2Nf71Wg~nw7EAY(aM|RD6X}`-Zx_vTTeoF!9gje>9`Gf;C1g01yvziaI z; Query(Query query) - { - var histories = QueryHistoryStorage.Instance.GetHistory(); - string filter = query.Search; - if (!string.IsNullOrEmpty(filter)) - { - histories = histories.Where(o => o.Query.Contains(filter)).ToList(); - } - return histories.Select(history => new Result() - { - Title = history.Query, - SubTitle = history.GetTimeAgo(), - IcoPath = "Images\\history.png", - Action = _ => - { - context.API.ChangeQuery(history.Query); - return false; - } - }).ToList(); - } - - public void Init(PluginInitContext context) - { - this.context = context; - } - - void API_BeforeWoxQueryEvent(WoxQueryEventArgs e) - { - Thread.Sleep(5000); - } - - private void API_AfterWoxQueryEvent(WoxQueryEventArgs e) - { - QueryHistoryStorage.Instance.Add(e.Query.RawQuery); - } - } -} diff --git a/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs b/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs deleted file mode 100644 index 3d10f4a491..0000000000 --- a/Plugins/Wox.Plugin.QueryHistory/QueryHistoryStorage.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Newtonsoft.Json; -using Wox.Core.Exception; -using Wox.Infrastructure.Storage; - -namespace Wox.Plugin.QueryHistory -{ - public class QueryHistoryStorage : JsonStrorage - { - [JsonProperty] - private List History = new List(); - - private int MaxHistory = 300; - private int cursor = 0; - - protected override string ConfigFolder - { - get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - } - - protected override string ConfigName - { - get { return "QueryHistory"; } - } - - public HistoryItem Pop() - { - if (History.Count == 0) return null; - - if (cursor > History.Count - 1) - { - cursor = History.Count - 1; - } - if (cursor < 0) - { - cursor = 0; - } - - return History[cursor--]; - } - - public void Reset() - { - cursor = History.Count - 1; - } - - public void Add(string query) - { - if (string.IsNullOrEmpty(query)) return; - if (History.Count > MaxHistory) - { - History.RemoveAt(0); - } - - if (History.Count > 0 && History.Last().Query == query) - { - History.Last().ExecutedDateTime = DateTime.Now; - } - else - { - History.Add(new HistoryItem() - { - Query = query, - ExecutedDateTime = DateTime.Now - }); - } - - if (History.Count % 5 == 0) - { - Save(); - } - } - - public List GetHistory() - { - return History.OrderByDescending(o => o.ExecutedDateTime).ToList(); - } - } -} diff --git a/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj b/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj deleted file mode 100644 index 34fc2868db..0000000000 --- a/Plugins/Wox.Plugin.QueryHistory/Wox.Plugin.QueryHistory.csproj +++ /dev/null @@ -1,85 +0,0 @@ - - - - - Debug - AnyCPU - {B552DCB6-692E-4B1D-9E0B-9096A2A7E6B0} - Library - Properties - Wox.Plugin.QueryHistory - Wox.Plugin.QueryHistory - v3.5 - 512 - ..\..\ - - - true - full - false - ..\..\Output\Debug\Plugins\Wox.Plugin.QueryHistory\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\Output\Release\Plugins\Wox.Plugin.QueryHistory\ - TRACE - prompt - 4 - - - - False - ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll - - - - - - - - - - - - - - - - - {B749F0DB-8E75-47DB-9E5E-265D16D0C0D2} - Wox.Core - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - {8451ecdd-2ea4-4966-bb0a-7bbc40138e80} - Wox.Plugin - - - - - - PreserveNewest - - - - - PreserveNewest - - - - - - diff --git a/Plugins/Wox.Plugin.QueryHistory/packages.config b/Plugins/Wox.Plugin.QueryHistory/packages.config deleted file mode 100644 index 7a13476a54..0000000000 --- a/Plugins/Wox.Plugin.QueryHistory/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Plugins/Wox.Plugin.QueryHistory/plugin.json b/Plugins/Wox.Plugin.QueryHistory/plugin.json deleted file mode 100644 index 959874b682..0000000000 --- a/Plugins/Wox.Plugin.QueryHistory/plugin.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ID":"54F327C503414B9489CDD331EE9472EF", - "ActionKeyword":"history", - "Name":"Query History", - "Description":"Remember Wox query history", - "Author":"qianlifeng", - "Version":"1.0.0", - "Language":"csharp", - "Website":"http://www.getwox.com/plugin", - "ExecuteFileName":"Wox.Plugin.QueryHistory.dll", - "IcoPath":"Images\\history.png" -} \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/ConfigStorage.cs b/Wox.UpdateFeedGenerator/ConfigStorage.cs deleted file mode 100644 index a7dcbc35cf..0000000000 --- a/Wox.UpdateFeedGenerator/ConfigStorage.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.IO; -using System.Reflection; -using Newtonsoft.Json; -using Wox.Infrastructure.Storage; - -namespace Wox.UpdateFeedGenerator -{ - public class ConfigStorage : JsonStrorage - { - [JsonProperty] - public string OutputDirectory { get; set; } - - [JsonProperty] - public string SourceDirectory { get; set; } - - [JsonProperty] - public string BaseURL { get; set; } - - [JsonProperty] - public string FeedXMLName { get; set; } - - [JsonProperty] - public bool CheckVersion { get; set; } - - [JsonProperty] - public bool CheckSize { get; set; } - - [JsonProperty] - public bool CheckDate { get; set; } - - [JsonProperty] - public bool CheckHash { get; set; } - - protected override void OnAfterLoad(ConfigStorage config) - { - if (string.IsNullOrEmpty(config.OutputDirectory)) - { - config.OutputDirectory = @"Update"; - Instance.Save(); - } - } - - protected override string FileName { get; } = "config"; - } -} diff --git a/Wox.UpdateFeedGenerator/FileInfoEx.cs b/Wox.UpdateFeedGenerator/FileInfoEx.cs deleted file mode 100644 index c02704157e..0000000000 --- a/Wox.UpdateFeedGenerator/FileInfoEx.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Diagnostics; -using System.IO; -using NAppUpdate.Framework.Utils; - -namespace Wox.UpdateFeedGenerator -{ - public class FileInfoEx - { - private readonly FileInfo myFileInfo; - private readonly string myFileVersion; - private readonly string myHash; - - public FileInfo FileInfo - { - get { return myFileInfo; } - } - - public string FileVersion - { - get { return myFileVersion; } - } - - public string Hash - { - get { return myHash; } - } - - public string RelativeName { get; private set; } - - public FileInfoEx(string fileName,int rootDirectoryLength) - { - myFileInfo = new FileInfo(fileName); - myFileVersion = FileVersionInfo.GetVersionInfo(fileName).FileVersion; - if (myFileVersion != null) myFileVersion = myFileVersion.Replace(", ", "."); - myHash = FileChecksum.GetSHA256Checksum(fileName); - RelativeName = fileName.Substring(rootDirectoryLength + 1); - } - } -} diff --git a/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs b/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs deleted file mode 100644 index b087f9d4d2..0000000000 --- a/Wox.UpdateFeedGenerator/FileSystemEnumerator.cs +++ /dev/null @@ -1,248 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; -using System.Security.Permissions; -using System.Text.RegularExpressions; -using Microsoft.Win32.SafeHandles; -using Wox.UpdateFeedGenerator.Win32; - -namespace Wox.UpdateFeedGenerator -{ - namespace Win32 - { - /// - /// Structure that maps to WIN32_FIND_DATA - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - internal sealed class FindData - { - public int fileAttributes; - public int creationTime_lowDateTime; - public int creationTime_highDateTime; - public int lastAccessTime_lowDateTime; - public int lastAccessTime_highDateTime; - public int lastWriteTime_lowDateTime; - public int lastWriteTime_highDateTime; - public int nFileSizeHigh; - public int nFileSizeLow; - public int dwReserved0; - public int dwReserved1; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public String fileName; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] public String alternateFileName; - } - - /// - /// SafeHandle class for holding find handles - /// - internal sealed class SafeFindHandle : SafeHandleMinusOneIsInvalid - { - /// - /// Constructor - /// - public SafeFindHandle() : base(true) {} - - /// - /// Release the find handle - /// - /// true if the handle was released - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - protected override bool ReleaseHandle() - { - return SafeNativeMethods.FindClose(handle); - } - } - - /// - /// Wrapper for P/Invoke methods used by FileSystemEnumerator - /// - [SecurityPermission(SecurityAction.Assert, UnmanagedCode = true)] - internal static class SafeNativeMethods - { - [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] - public static extern SafeFindHandle FindFirstFile(String fileName, [In, Out] FindData findFileData); - - [DllImport("kernel32", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool FindNextFile(SafeFindHandle hFindFile, [In, Out] FindData lpFindFileData); - - [DllImport("kernel32", CharSet = CharSet.Auto)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool FindClose(IntPtr hFindFile); - } - } - - /// - /// File system enumerator. This class provides an easy to use, efficient mechanism for searching a list of - /// directories for files matching a list of file specifications. The search is done incrementally as matches - /// are consumed, so the overhead before processing the first match is always kept to a minimum. - /// - public sealed class FileSystemEnumerator : IDisposable - { - /// - /// Information that's kept in our stack for simulated recursion - /// - private struct SearchInfo - { - /// - /// Find handle returned by FindFirstFile - /// - public readonly SafeFindHandle Handle; - - /// - /// Path that was searched to yield the find handle. - /// - public readonly string Path; - - /// - /// Constructor - /// - /// Find handle returned by FindFirstFile. - /// Path corresponding to find handle. - public SearchInfo(SafeFindHandle h, string p) - { - Handle = h; - Path = p; - } - } - - /// - /// Stack of open scopes. This is a member (instead of a local variable) - /// to allow Dispose to close any open find handles if the object is disposed - /// before the enumeration is completed. - /// - private readonly Stack m_scopes; - - /// - /// Array of paths to be searched. - /// - private readonly string[] m_paths; - - /// - /// Array of regular expressions that will detect matching files. - /// - private readonly List m_fileSpecs; - - /// - /// If true, sub-directories are searched. - /// - private readonly bool m_includeSubDirs; - - #region IDisposable implementation - - /// - /// IDisposable.Dispose - /// - public void Dispose() - { - while (m_scopes.Count > 0) { - SearchInfo si = m_scopes.Pop(); - si.Handle.Close(); - } - } - - #endregion - - /// - /// Constructor. - /// - /// Semicolon- or comma-delimitted list of paths to search. - /// Semicolon- or comma-delimitted list of wildcard filespecs to match. - /// If true, subdirectories are searched. - public FileSystemEnumerator(string pathsToSearch, string fileTypesToMatch, bool includeSubDirs) - { - m_scopes = new Stack(); - - // check for nulls - if (null == pathsToSearch) throw new ArgumentNullException("pathsToSearch"); - if (null == fileTypesToMatch) throw new ArgumentNullException("fileTypesToMatch"); - - // make sure spec doesn't contain invalid characters - if (fileTypesToMatch.IndexOfAny(new[] { ':', '<', '>', '/', '\\' }) >= 0) throw new ArgumentException("invalid cahracters in wildcard pattern", "fileTypesToMatch"); - - m_includeSubDirs = includeSubDirs; - m_paths = pathsToSearch.Split(';', ','); - - string[] specs = fileTypesToMatch.Split(';', ','); - m_fileSpecs = new List(specs.Length); - foreach (string spec in specs) { - // trim whitespace off file spec and convert Win32 wildcards to regular expressions - string pattern = spec.Trim().Replace(".", @"\.").Replace("*", @".*").Replace("?", @".?"); - m_fileSpecs.Add(new Regex("^" + pattern + "$", RegexOptions.IgnoreCase)); - } - } - - /// - /// Get an enumerator that returns all of the files that match the wildcards that - /// are in any of the directories to be searched. - /// - /// An IEnumerable that returns all matching files one by one. - /// - /// The enumerator that is returned finds files using a lazy algorithm that - /// searches directories incrementally as matches are consumed. - /// - public IEnumerable Matches() - { - foreach (string rootPath in m_paths) { - string path = rootPath.Trim(); - - // we "recurse" into a new directory by jumping to this spot - top: - - // check security - ensure that caller has rights to read this directory - new FileIOPermission(FileIOPermissionAccess.PathDiscovery, Path.Combine(path, ".")).Demand(); - - // now that security is checked, go read the directory - FindData findData = new FindData(); - SafeFindHandle handle = SafeNativeMethods.FindFirstFile(Path.Combine(path, "*"), findData); - m_scopes.Push(new SearchInfo(handle, path)); - bool restart = false; - - // we "return" from a sub-directory by jumping to this spot - restart: -// ReSharper disable InvertIf - if (!handle.IsInvalid) { -// ReSharper restore InvertIf - do { - // if we restarted the loop (unwound a recursion), fetch the next match - if (restart) { - restart = false; - continue; - } - - // don't match . or .. - if (findData.fileName.Equals(@".") || findData.fileName.Equals(@"..")) continue; - - if ((findData.fileAttributes & (int)FileAttributes.Directory) != 0) { - if (m_includeSubDirs) { - // it's a directory - recurse into it - path = Path.Combine(path, findData.fileName); - goto top; - } - } else { - // it's a file, see if any of the filespecs matches it - foreach (Regex fileSpec in m_fileSpecs) { - // if this spec matches, return this file's info - if (fileSpec.IsMatch(findData.fileName)) yield return new FileInfo(Path.Combine(path, findData.fileName)); - } - } - } while (SafeNativeMethods.FindNextFile(handle, findData)); - - // close this find handle - handle.Close(); - - // unwind the stack - are we still in a recursion? - m_scopes.Pop(); - if (m_scopes.Count > 0) { - SearchInfo si = m_scopes.Peek(); - handle = si.Handle; - path = si.Path; - restart = true; - goto restart; - } - } - } - } - } -} diff --git a/Wox.UpdateFeedGenerator/Generator.cs b/Wox.UpdateFeedGenerator/Generator.cs deleted file mode 100644 index 9444254895..0000000000 --- a/Wox.UpdateFeedGenerator/Generator.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Threading; -using System.Xml; - -namespace Wox.UpdateFeedGenerator -{ - public class Generator - { - private string OutputDirectory; - private string SourceDirectory; - private string BaseURL = ConfigStorage.Instance.BaseURL; - private string feedXMLPath; - private bool checkVersion = ConfigStorage.Instance.CheckVersion; - private bool checkSize = ConfigStorage.Instance.CheckSize; - private bool checkDate = ConfigStorage.Instance.CheckDate; - private bool checkHash = ConfigStorage.Instance.CheckHash; - - public Generator() - { - OutputDirectory = Path.GetFullPath(ConfigStorage.Instance.OutputDirectory); - SourceDirectory = Path.GetFullPath(ConfigStorage.Instance.SourceDirectory); - feedXMLPath = Path.Combine(ConfigStorage.Instance.OutputDirectory, ConfigStorage.Instance.FeedXMLName); - } - - private List ReadSourceFiles() - { - List files = new List(); - FileSystemEnumerator enumerator = new FileSystemEnumerator(SourceDirectory, "*.*", true); - foreach (FileInfo fi in enumerator.Matches()) - { - string file = fi.FullName; - if ((IsIgnorable(file))) continue; - FileInfoEx thisInfo = new FileInfoEx(file, SourceDirectory.Length); - files.Add(thisInfo); - } - return files; - } - - private bool IsIgnorable(string thisFile) - { - return false; - } - - public void Build() - { - Console.WriteLine("Building Wox update feed"); - if (!Directory.Exists(OutputDirectory)) - { - Directory.CreateDirectory(OutputDirectory); - } - - XmlDocument doc = new XmlDocument(); - XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); - - doc.AppendChild(dec); - XmlElement feed = doc.CreateElement("Feed"); - feed.SetAttribute("BaseUrl", BaseURL.Trim()); - doc.AppendChild(feed); - - XmlElement tasks = doc.CreateElement("Tasks"); - - foreach (FileInfoEx file in ReadSourceFiles()) - { - Console.WriteLine("adding {0} to feed xml.", file.FileInfo.FullName); - XmlElement task = doc.CreateElement("FileUpdateTask"); - task.SetAttribute("localPath", file.RelativeName); - - // generate FileUpdateTask metadata items - task.SetAttribute("lastModified", file.FileInfo.LastWriteTime.ToFileTime().ToString(CultureInfo.InvariantCulture)); - task.SetAttribute("fileSize", file.FileInfo.Length.ToString(CultureInfo.InvariantCulture)); - if (!string.IsNullOrEmpty(file.FileVersion)) task.SetAttribute("version", file.FileVersion); - - XmlElement conds = doc.CreateElement("Conditions"); - XmlElement cond; - bool hasFirstCondition = false; - - //File Exists - cond = doc.CreateElement("FileExistsCondition"); - cond.SetAttribute("type", "or"); - conds.AppendChild(cond); - - //Version - if (checkVersion && !string.IsNullOrEmpty(file.FileVersion)) - { - cond = doc.CreateElement("FileVersionCondition"); - cond.SetAttribute("what", "below"); - cond.SetAttribute("version", file.FileVersion); - conds.AppendChild(cond); - hasFirstCondition = true; - } - - //Size - if (checkSize) - { - cond = doc.CreateElement("FileSizeCondition"); - cond.SetAttribute("type", hasFirstCondition ? "or-not" : "not"); - cond.SetAttribute("what", "is"); - cond.SetAttribute("size", file.FileInfo.Length.ToString(CultureInfo.InvariantCulture)); - conds.AppendChild(cond); - } - - //Date - if (checkDate) - { - cond = doc.CreateElement("FileDateCondition"); - if (hasFirstCondition) cond.SetAttribute("type", "or"); - cond.SetAttribute("what", "older"); - // local timestamp, not UTC - cond.SetAttribute("timestamp", file.FileInfo.LastWriteTime.ToFileTime().ToString(CultureInfo.InvariantCulture)); - conds.AppendChild(cond); - } - - //Hash - if (checkHash) - { - cond = doc.CreateElement("FileChecksumCondition"); - cond.SetAttribute("type", hasFirstCondition ? "or-not" : "not"); - cond.SetAttribute("checksumType", "sha256"); - cond.SetAttribute("checksum", file.Hash); - conds.AppendChild(cond); - } - - task.AppendChild(conds); - tasks.AppendChild(task); - string destFile = Path.Combine(OutputDirectory, file.RelativeName); - CopyFile(file.FileInfo.FullName, destFile); - } - feed.AppendChild(tasks); - doc.Save(feedXMLPath); - } - - private bool CopyFile(string sourceFile, string destFile) - { - // If the target folder doesn't exist, create the path to it - var fi = new FileInfo(destFile); - var d = Directory.GetParent(fi.FullName); - if (!Directory.Exists(d.FullName)) CreateDirectoryPath(d.FullName); - - // Copy with delayed retry - int retries = 3; - while (retries > 0) - { - try - { - if (File.Exists(destFile)) File.Delete(destFile); - File.Copy(sourceFile, destFile); - retries = 0; // success - return true; - } - catch (IOException) - { - // Failed... let's try sleeping a bit (slow disk maybe) - if (retries-- > 0) Thread.Sleep(200); - } - catch (UnauthorizedAccessException) - { - // same handling as IOException - if (retries-- > 0) Thread.Sleep(200); - } - } - return false; - } - - private void CreateDirectoryPath(string directoryPath) - { - // Create the folder/path if it doesn't exist, with delayed retry - int retries = 3; - while (retries > 0 && !Directory.Exists(directoryPath)) - { - Directory.CreateDirectory(directoryPath); - if (retries-- < 3) Thread.Sleep(200); - } - } - - } -} diff --git a/Wox.UpdateFeedGenerator/Program.cs b/Wox.UpdateFeedGenerator/Program.cs deleted file mode 100644 index d2b3f274e6..0000000000 --- a/Wox.UpdateFeedGenerator/Program.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Wox.UpdateFeedGenerator -{ - class Program - { - static void Main(string[] args) - { - new Generator().Build(); - } - } -} diff --git a/Wox.UpdateFeedGenerator/Properties/AssemblyInfo.cs b/Wox.UpdateFeedGenerator/Properties/AssemblyInfo.cs deleted file mode 100644 index 33c0c07f30..0000000000 --- a/Wox.UpdateFeedGenerator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("Wox.UpdateFeedGenerator")] -[assembly: Guid("2f3420c0-2c21-4f71-a45d-a47b5305fe20")] \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/README.md b/Wox.UpdateFeedGenerator/README.md deleted file mode 100644 index 00741d2ac0..0000000000 --- a/Wox.UpdateFeedGenerator/README.md +++ /dev/null @@ -1 +0,0 @@ -NAppUpdate feed generator for Wox. It's something like [FeedBuilder](https://github.com/synhershko/NAppUpdate/tree/master/FeedBuilder) \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj b/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj deleted file mode 100644 index b4f7c27f2d..0000000000 --- a/Wox.UpdateFeedGenerator/Wox.UpdateFeedGenerator.csproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - - Debug - AnyCPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F} - Exe - Properties - Wox.UpdateFeedGenerator - Wox.UpdateFeedGenerator - v4.5.2 - 512 - ..\ - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\NAppUpdate.Framework.0.3.2.0\lib\net20\NAppUpdate.Framework.dll - True - - - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - True - - - - - - - - - - - Properties\SolutionAssemblyInfo.cs - - - - - - - - - - - - Designer - - - - - - {4fd29318-a8ab-4d8f-aa47-60bc241b8da3} - Wox.Infrastructure - - - - - \ No newline at end of file diff --git a/Wox.UpdateFeedGenerator/app.config b/Wox.UpdateFeedGenerator/app.config deleted file mode 100644 index ff99501038..0000000000 --- a/Wox.UpdateFeedGenerator/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/Wox.UpdateFeedGenerator/packages.config b/Wox.UpdateFeedGenerator/packages.config deleted file mode 100644 index aba1c6d1b0..0000000000 --- a/Wox.UpdateFeedGenerator/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Wox.sln b/Wox.sln index 9bbdd00d60..7fb7e702ba 100644 --- a/Wox.sln +++ b/Wox.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.25029.0 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Test", "Wox.Test\Wox.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}" ProjectSection(ProjectDependencies) = postProject @@ -18,7 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{3A73 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox", "Wox\Wox.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}" ProjectSection(ProjectDependencies) = postProject - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F} = {D120E62B-EC59-4FB4-8129-EFDD4C446A5F} {230AE83F-E92E-4E69-8355-426B305DA9C0} = {230AE83F-E92E-4E69-8355-426B305DA9C0} {1EE20B48-82FB-48A2-8086-675D6DDAB4F0} = {1EE20B48-82FB-48A2-8086-675D6DDAB4F0} {0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {0B9DE348-9361-4940-ADB6-F5953BFFCCEC} @@ -71,8 +70,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.CrashReporter", "Wox.Cr {88731DA8-C020-476E-B79A-3ADEF65ACA9F} = {88731DA8-C020-476E-B79A-3ADEF65ACA9F} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.UpdateFeedGenerator", "Wox.UpdateFeedGenerator\Wox.UpdateFeedGenerator.csproj", "{D120E62B-EC59-4FB4-8129-EFDD4C446A5F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.Everything", "Plugins\Wox.Plugin.Everything\Wox.Plugin.Everything.csproj", "{230AE83F-E92E-4E69-8355-426B305DA9C0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FFD651C7-0546-441F-BC8C-D4EE8FD01EA7}" @@ -301,14 +298,6 @@ Global {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x64.Build.0 = Release|Any CPU {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x86.ActiveCfg = Release|Any CPU {2FEB2298-7653-4009-B1EA-FFFB1A768BCC}.Release|x86.Build.0 = Release|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|x64.ActiveCfg = Debug|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Debug|x86.ActiveCfg = Debug|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|Any CPU.Build.0 = Release|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|x64.ActiveCfg = Release|Any CPU - {D120E62B-EC59-4FB4-8129-EFDD4C446A5F}.Release|x86.ActiveCfg = Release|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|Any CPU.Build.0 = Debug|Any CPU {230AE83F-E92E-4E69-8355-426B305DA9C0}.Debug|x64.ActiveCfg = Debug|Any CPU