Exemple #1
0
        public static void CreateCache(string path)
        {
            var re = new RootEntry();

            try
            {
                re.SimpleScanCountEvent = ScanCountPrintDot;
                re.SimpleScanEndEvent   = ScanEndofEntries;
                re.ExceptionEvent       = PrintExceptions;

                re.PopulateRoot(path);
                if (Hack.BreakConsoleFlag)
                {
                    Console.WriteLine(" * Break key detected incomplete scan will not be saved.");
                    return;
                }

                var oldRoot = RootEntry.LoadDirCache(re.DefaultFileName);
                if (oldRoot != null)
                {
                    Console.WriteLine($"Found cache \"{re.DefaultFileName}\"");
                    Console.WriteLine("Updating hashs on new scan from found cache file.");
                    oldRoot.TraverseTreesCopyHash(re);
                }
                re.SortAllChildrenByPath();
                re.SaveRootEntry();
                var scanTimeSpan = (re.ScanEndUTC - re.ScanStartUTC);
                Console.WriteLine($"Scanned Path {re.Path}");
                Console.WriteLine($"Scan time {scanTimeSpan.TotalMilliseconds:0.00} msecs");
                Console.WriteLine($"Saved Scanned Path {re.DefaultFileName}");
                Console.WriteLine(
                    $"Files {re.FileEntryCount:0,0} Dirs {re.DirEntryCount:0,0} Total Size of Files {re.Size:0,0}");
            }
            catch (ArgumentException aex)
            {
                Console.WriteLine($"Error: {aex.Message}");
            }
        }