public void RefreshDirectory() { InitializeDirectory(); options.InitialDirectory = directory.FullName; filesView.RsaFileColor = options.RsaFileColor.Color; addressToolBar.PathChanged -= addressToolBar_PathChanged; addressToolBar.Path = directory.FullName; addressToolBar.PathChanged += addressToolBar_PathChanged; var files = directory.GetFiles(); var directories = directory.GetDirectories(); files.AddRange(directories); var sortingInfo = sorter.GetSortingInfo(); options.InitialSortColumn = sortingInfo.SortColumn; options.InitialSortDirection = sortingInfo.SortDirection; filesView.SortingInfo = sortingInfo; sorter.Sort(files); filesView.SetFileSystemEntities(files); var parent = directory.GetParentDirectory(); filesView.IsTerminal = parent == null; toolBarView.ToUpperDirectoryEnabled = parent != null; filesView.ResizeColumns(); }
private IEnumerable <IFileInfo> GetSortedFiles(IDirectoryInfo src, string pattern, PodcastFileSortField sortField, bool ascendingSort) { try { var fileList = new Collection <IFileInfo>(src.GetFiles(pattern)); return(FileSorter.Sort(fileList, sortField, ascendingSort)); } catch (DirectoryNotFoundException) { // if the folder is not there then there is nothing to do return(new Collection <IFileInfo>()); } }
private static int ExecuteSort(SortOptions options) { if (!options.Validate()) { return(1); } var sorter = new FileSorter(options); var timer = Stopwatch.StartNew(); Console.WriteLine($"File '{options.Input}' sort started..."); sorter.Sort(); Console.WriteLine($"File sort executed at {timer.Elapsed}"); return(0); }
static void Main(string[] args) { var fileSorterParams = new FileSorterParams() { InputDataFileName = "TestData_1Gb.txt", MaxMemoryUsageInBytes = 2 * 1024L * 1024L * 1024L, OutputSortedFileName = "SortedTestData.txt", SplittedFileSizeInBytes = 50 * 1024L * 1024L, SplittedFilesDirectoryName = "TempData", ProgressInformer = new ConsoleProgressInformer() }; var fileSorter = new FileSorter(fileSorterParams); var isSuccess = fileSorter.Sort(); Console.WriteLine($"Is success sorting: {isSuccess}"); Console.ReadLine(); }
public void FileSorter_should_sort_file(string inputPath) { var outputPath = $"{inputPath}.sort_test"; var bufferSize = 65 * 1024 * 1024; var sorter = new FileSorter <TestLine>( new TestLineParser(), new LinqSortStrategy( new TestLineComparer() ), new TestLineComparer(), new FileAdapter(), new FileReader(), new FileWriter()); sorter.Sort(inputPath, outputPath, bufferSize, bufferSize); Check_sorting(outputPath); Check_for_brocken_line(outputPath); }
public static void Main(string[] args) { string fileName; if (args.Length < 1) { Console.Write("File name: "); fileName = Console.ReadLine(); } else { fileName = args[0]; } if (!File.Exists(fileName)) { Console.WriteLine($"File '{fileName}' doesn't exist."); } var options = Options.Create(new FileSorterOptions { BatchSize = 50000 }); var sorter = new FileSorter(options); var outFileName = FileSorter.DefaultOutFileName(fileName); var sw = new Stopwatch(); sw.Start(); Task.WaitAll(sorter.Sort(fileName, outFileName, CancellationToken.None)); sw.Stop(); Console.WriteLine($"Sorted. Output: '{outFileName}', elapsed: {sw.Elapsed.TotalSeconds:0.000} s."); }
protected override void When() { SortedFiles = FileSorter.Sort(OriginalFiles, PodcastFileSortField.CreationTime, false); }
protected override void When() { SortedFiles = FileSorter.Sort(OriginalFiles, PodcastFileSortField.FileName, true); }