コード例 #1
0
        /// <summary>
        /// Generates an index using the given filelist.
        /// </summary>
        /// <param name="filelist">The list of files to index.</param>
        public Task Index(List <string> filelist = null)
        {
            return(Task.Run(() =>
            {
                Application.Current.Dispatcher.Invoke(() => {
                    DataContext.IsIndexing = true;
                });
                if (filelist == null)
                {
                    GeneralHelper.WriteToConsole($"Retrieving file list.\n");
                    filelist = FileHelper.DirectorySearch(@"\\?\" + Path.GetFullPath("UnpackedData"));
                }

                // Display total file count being indexed
                GeneralHelper.WriteToConsole($"File list retrieved.\n");
                Application.Current.Dispatcher.Invoke(() =>
                {
                    DataContext.IndexFileTotal = filelist.Count;
                    DataContext.IndexStartTime = DateTime.Now;
                    DataContext.IndexFileCount = 0;
                });

                if (System.IO.Directory.Exists(luceneIndex))
                {
                    System.IO.Directory.Delete(luceneIndex, true);
                }
                IndexFiles(filelist, new CustomAnalyzer());
            }));
        }
コード例 #2
0
        /// <summary>
        /// Builds a pack from converted files.
        /// </summary>
        /// <param name="path">The mod root path.</param>
        /// <returns>The new mod build directory.</returns>
        private static string BuildPack(string path)
        {
            var fileList = FileHelper.DirectorySearch(path);
            var modDir   = $"{TempFolder}\\{new DirectoryInfo(path).Name}";

            foreach (var file in fileList)
            {
                var fileParent      = file.Replace(path, string.Empty).Replace("\\\\?\\", string.Empty);
                var fileName        = Path.GetFileName(file);
                var extension       = Path.GetExtension(fileName);
                var conversionFile  = fileName.Replace(extension, string.Empty);
                var secondExtension = Path.GetExtension(conversionFile);
                // copy to temp dir
                var mod       = $"\\\\?\\{modDir}{fileParent}";
                var modParent = new DirectoryInfo(mod).Parent.FullName;
                if (string.IsNullOrEmpty(secondExtension))
                {
                    if (!Directory.Exists(modParent))
                    {
                        Directory.CreateDirectory(modParent);
                    }
                    File.Copy(file, mod);
                }
                else
                {
                    // convert and save to temp dir
                    FileHelper.Convert(file, secondExtension.Remove(0, 1), $"{modParent}\\{conversionFile}");
                }
            }

            return(modDir);
        }
コード例 #3
0
 /// <summary>
 /// Decompresses all decompressable files recursively.
 /// </summary>
 /// <returns>The task with the list of all decompressable files.</returns>
 public static Task <List <string> > DecompressAllConvertableFiles()
 {
     return(Task.Run(() =>
     {
         GeneralHelper.WriteToConsole($"Retrieving file list for decompression.\n");
         var fileList = FileHelper.DirectorySearch(@"\\?\" + Path.GetFullPath("UnpackedData"));
         GeneralHelper.WriteToConsole($"Retrived file list. Starting decompression; this could take awhile.\n");
         var defaultPath = @"\\?\" + FileHelper.GetPath("");
         var lsxFiles = new List <string>();
         Parallel.ForEach(fileList, file => {
             if (!string.IsNullOrEmpty(Path.GetExtension(file)))
             {
                 var convertedFile = FileHelper.Convert(file.Replace(defaultPath, ""), "lsx");
                 if (Path.GetExtension(convertedFile) == ".lsx")
                 {
                     lsxFiles.Add(convertedFile);
                 }
             }
         });
         fileList.Clear();
         GeneralHelper.WriteToConsole($"Decompression complete.\n");
         return lsxFiles;
     }));
 }