예제 #1
0
        public static void CreateSnapshot(CreateOptions o)
        {
            var(parent, blobs) = FileFetcher.FindBlobs(
                o.Files,
                new Fuzzy(
                    o.ExcludePatterns,
                    FuzzyOption.EmptyMatchesNothing));

            if (blobs.Length == 0)
            {
                Console.WriteLine("Empty file list. Nothing to do!");
                return;
            }

            var snapshotStore = CreateSnapshotStore(o.Repository);

            snapshotStore.StoreSnapshot(
                blobs,
                new Fuzzy(
                    o.ScanPatterns,
                    FuzzyOption.EmptyMatchesNothing),
                DateTime.UtcNow,
                blobName => File.OpenRead(
                    Path.Combine(parent, blobName)));
        }
예제 #2
0
        public static void PreviewSnapshot(PreviewOptions o)
        {
            var(_, blobs) = FileFetcher.FindBlobs(
                o.Files,
                new Fuzzy(
                    o.ExcludePatterns,
                    FuzzyOption.EmptyMatchesNothing));

            if (blobs.Length == 0)
            {
                Console.WriteLine("Empty file list. Nothing to do!");
                return;
            }

            var snapshotStore = CreateSnapshotStore(o.Repository);

            var snapshotBlobs = snapshotStore.IsEmpty
                ? Array.Empty <Blob>()
                : snapshotStore.ShowSnapshot(
                o.SnapshotId,
                Fuzzy.MatchAll)
                                .Select(blobReference => blobReference.ToBlob())
                                .ToArray();

            var diff = DiffSet.Create(
                snapshotBlobs,
                blobs,
                blob => blob.Name,
                (b1, b2) => b1.Equals(b2));

            PrintDiff(diff);
        }
예제 #3
0
        public void CanReadTextFilesInSearchableDirectory()
        {
            var fileFetcher = new FileFetcher(new[] { AppDomain.CurrentDomain.BaseDirectory });

            var str = fileFetcher.GetText(@"\data\small.txt");

            Assert.AreEqual("hi buddy", str);
        }
예제 #4
0
        public void CanReadTextFilesRelitiveToBaseDirector()
        {
            var fileFetcher = new FileFetcher();

            var str = fileFetcher.GetText(@"~\data\small.txt");

            Assert.AreEqual("hi buddy", str);
        }
예제 #5
0
        public void CanReadTextFiles()
        {
            var fileFetcher = new FileFetcher();

            var str = fileFetcher.GetText(@"\data\small.txt");

            Assert.AreEqual("hi buddy", str);
        }
예제 #6
0
        public void CanReadTextFilesDirectly()
        {
            var fileFetcher = new FileFetcher();

            var str = fileFetcher.GetText(AppDomain.CurrentDomain.BaseDirectory + @"\data\small.txt");

            Assert.AreEqual("hi buddy", str);
        }
        public static void ShutdownApplication()
        {
            ShutdownWindows();

            Main.Closing -= WindowClosing;
            Help.Closing -= WindowClosing;

            FileFetcher.ForceStop();
            IconFetcher.ForceStop();

            Application.Shutdown();
        }
        public ExplorerViewModel()
        {
            Files = new ObservableCollection <FileViewModel>();

            Navigator          = new FileNavigationViewModel();
            Navigator.Explorer = this;

            FileFetcher.Initialise();
            IconFetcher.Initialise();
            FileFetcher.DirectoryFetchedCallback   = OnDirectoryFetched;
            FileFetcher.FileFetchedCallback        = OnFileFetched;
            FileFetcher.DirectoriesFetchedCallback = FoundDirectories;
            FileFetcher.FilesFetchedCallback       = FoundFiles;
        }
예제 #9
0
 public void Dispose()
 {
     FileFetcher.CancelDownload();
     lock (machLock)
     {
         PauseAll();
         Array.ForEach(machs.Rights, x => x.Dispose());
         machs.Clear();
         MasterTimeSource.Dispose();
         ExternalsManager.Clear();
         HostMachine.Dispose();
         CurrentLogger.Dispose();
         BackendManager.Dispose();
     }
 }
예제 #10
0
 public void Dispose()
 {
     FileFetcher.CancelDownload();
     lock (machLock)
     {
         var toDispose = machs.Rights.ToArray();
         //Although a single machine does not have to be paused before its disposal,
         //disposing multiple entities has to ensure that all are stopped.
         ExternalsManager.Pause();
         Array.ForEach(toDispose, x => x.Pause());
         Array.ForEach(toDispose, x => x.Dispose());
         machs.Clear();
         ExternalsManager.Clear();
         HostMachine.Dispose();
         CurrentLogger.Dispose();
     }
 }
예제 #11
0
        static void Main(string[] args)
        {
            try
            {
                Parser.Default.ParseArguments <Options>(args).WithParsed(options =>
                {
                    Console.WriteLine($"\nRunning with following configuration. Category: {options.Category}, Directory: {options.Directory}\n");

                    string filename = options.Directory.Split('\\').Last();
                    (HashSet <string> extensions, string[] titles, Func <string, IExcelSerializer> map) = Profile.GetProfile(options.Category);

                    IExcelSerializer[] data = FileFetcher.GetFiles(options.Directory, extensions)
                                              .SelectSkipExceptions(map)
                                              .ToArray();
                    ExcelWriter.WriteToExcelFile(filename, titles, data);
                    Console.WriteLine($"\nFile Saved: {Path.Combine(options.Directory, filename)}\n");
                });
            }
            catch (Exception exception)
            {
                Console.WriteLine($"Program encountered an error: ${exception}. Please report the error on Github: https://github.com/anikait1/MusicExcelOrganizer/");
            }
        }
 public void NavigateToDirectory(string directoryPath)
 {
     FileFetcher.StopFetching();
     Files.Clear();
     FileFetcher.StartFetching(directoryPath);
 }
예제 #13
0
        public void FileNotFound()
        {
            var fileFetcher = new FileFetcher();

            Assert.Throws<FileNotFoundException>(() => fileFetcher.GetText(@"\does-not-exist.txt"));
        }
예제 #14
0
 static void Main(string[] args)
 {
     FileFetcher.GatherData();
     Console.ReadLine();
 }