Esempio n. 1
0
        public static void Main(string[] args)
        {
            ConsoleUtil.InitConsoleSettings("DeDup Scanner - Under Development");

            // ConfigFileUtil.DumpConfigFiles(Path.Combine(Environment.GetFolderPath((Environment.SpecialFolder.UserProfile)), @"Repos\FileUtilities\Config\"));

            string scanRootDir = FileUtil.SelectDirectory();

            baseName = FileUtil.GetBaseName(scanRootDir); // e.g. "<system name> Vol C"
            Console.WriteLine("Scanning files in '{0}'\n", scanRootDir);

            if ((scanRootDir == "") || (baseName == ""))
            {
                ConsoleUtil.WriteLineColor(String.Format("Error: scan directory '{0}' or directory name '{1}' is empty", scanRootDir, baseName),
                                           ConsoleColor.Red);
                ConsoleUtil.WaitForKeyPress();
                return;
            }

            Console.Write("File list name is '{0}'? ", baseName);
            string input = Console.ReadLine();

            if (input != String.Empty)
            {
                baseName = input;
            }

            if (FileUtil.IsSystemDrive(scanRootDir))
            {
                // All my current system drives are SSDs
                numThreads = numThreadsSolidStateDrive;
            }
            else
            {
                numThreads = numThreadsRotatingDrive;
            }

            Console.Write("Run with {0} threads? ", numThreads);
            input = Console.ReadLine();
            int i;

            if (Int32.TryParse(input, out i))
            {
                numThreads = i;
            }

            Console.WriteLine("\nCreating scan report files '{0} - File/Directory List.tsv'", baseName);
            Console.WriteLine("Read Buffer Size = {0}", FileUtil.FormatByteSize(ComputeFingerprint.ReadBufferSize));
            Console.WriteLine("Running {0} simultaneous threads on {1} hardware threads\n", numThreads, hardwareThreads);

            RunParallelScan.Run(baseName, scanRootDir, numThreads);

            ConsoleUtil.WaitForKeyPress();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            ConsoleUtil.InitConsoleSettings("CopyUniqueFiles - Under Development");

            // ConfigFileUtil.DumpConfigFiles(Path.Combine(Environment.GetFolderPath((Environment.SpecialFolder.UserProfile)), @"Repos\FileUtilities\Config\"));

            string scanRootDir = FileUtil.SelectDirectory();

            baseName = FileUtil.GetBaseName(scanRootDir); // e.g. "<system name> Vol C"
            Console.WriteLine("Copying unique files from '{0}'\n", scanRootDir);

            if ((scanRootDir == "") || (baseName == ""))
            {
                ConsoleUtil.WriteLineColor(String.Format("Error: scan directory '{0}' or directory name '{1}' is empty", scanRootDir, baseName),
                                           ConsoleColor.Red);
                ConsoleUtil.WaitForKeyPress();
                return;
            }

            Console.Write("Destination Volume is '{0}'?", destinationVolume);
            string input = Console.ReadLine();

            if (input != String.Empty)
            {
                destinationVolume = input;
            }
            if ((destinationVolume.Length != 2) || (destinationVolume[1] != ':') || (!FileUtil.TestWriteVolume(destinationVolume)))
            {
                ConsoleUtil.WriteLineColor(String.Format("Error: destination volume of '{0}' is not valid", destinationVolume),
                                           ConsoleColor.Red);
                ConsoleUtil.WaitForKeyPress();
                return;
            }
            CopyUniqueFile.SetDestinationVolume(destinationVolume);

            Console.Write("File list name is '{0}'? ", baseName);
            input = Console.ReadLine();
            if (input != String.Empty)
            {
                baseName = input;
            }
            CopyUniqueFile.SetSourceBaseName(baseName);

            if (FileUtil.IsSystemDrive(scanRootDir))
            {
                // All my current system drives are SSDs
                numThreads = numThreadsSolidStateDrive;
            }
            else
            {
                numThreads = numThreadsRotatingDrive;
            }

            bool copyFiles = ConsoleUtil.YesNoChoice("Copy files (Y|N)? ");

            if (copyFiles)
            {
                Console.WriteLine("   Copying unique files from '{0}' to {1}\n", scanRootDir, destinationVolume);
            }
            else
            {
                Console.WriteLine("   Scanning files and writing reports only\n");
            }

            CopyUniqueFile.SetOptionCopyFiles(copyFiles);

            CopyUniqueFile.SetOptionDivideFilesIntoCategories(ConsoleUtil.YesNoChoice("Divide files into categories (Y|N)? "));

            Console.Write("Run with {0} threads? ", numThreads);
            input = Console.ReadLine();
            int i;

            if (Int32.TryParse(input, out i))
            {
                numThreads = i;
            }

            Console.WriteLine("\nCreating report files '{0} - Unique Files Copied/Duplicate Files.tsv'", baseName);
            // Console.WriteLine("Read Buffer Size = {0}", FileUtil.FormatByteSize(ComputeFingerprint.ReadBufferSize));
            Console.WriteLine("Running {0} simultaneous threads on {1} hardware threads\n", numThreads, hardwareThreads);

            // Load in-memory database of existing files to check against for uniques
            fileDB = new FileDB();
            LoadFileLists.LoadBaseFileLists(fileDB);

            RunParallelScan.ScanAndCopyUniques(baseName, scanRootDir, numThreads, fileDB);

            ConsoleUtil.WaitForKeyPress();
        }