コード例 #1
0
ファイル: FileOutputHandler.cs プロジェクト: TastyWaffles/hic
        public void RunHandler()
        {
            using (HashAlgorithm algorithm = HashAlgorithm.Create(_options.Algorithm))
            {
                if (HashUtils.IsDirectory(_options.Source))
                {
                    DirectoryInfo info = new DirectoryInfo(_options.Source);
                    //Run on the base directory
                    RunOnDirectory(info, algorithm);

                    //Run on all subdirectories
                    if (_options.Recursive)
                    {
                        foreach (DirectoryInfo directoryInfo in info.EnumerateDirectories())
                        {
                            RunOnDirectory(directoryInfo, algorithm);
                        }
                    }
                }
                else
                {
                    //Run on single file
                    FileInfo fileInfo = new FileInfo(_options.Source);
                    if (fileInfo.Exists)
                    {
                        RunOnFile(fileInfo, algorithm);
                    }
                }
            }
        }
コード例 #2
0
ファイル: RenameHandler.cs プロジェクト: TastyWaffles/hic
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="options">Parsed command line arguments</param>
        public RenameHandler(RenameFilesOptions options)
        {
            _options = options;

            string source = HashUtils.IsDirectory(_options.Source) ? _options.Source : Directory.GetCurrentDirectory();

            _rootParentDir = new DirectoryInfo(source);

            _outputDir = new DirectoryInfo(HashUtils.GetOutputDirectory(_options));
            if (!_outputDir.Exists)
            {
                _outputDir.Create();
            }

            _supportedExtensions = HashUtils.SupportedExtensions; //.Intersect(_options.ExcludedFileExtensions); todo
        }
コード例 #3
0
ファイル: RenameHandler.cs プロジェクト: TastyWaffles/hic
        /// <summary>
        /// Run the Rename Handler
        /// </summary>
        public void RunHandler()
        {
            if (HashUtils.IsDirectory(_options.Source))
            {
                DirectoryInfo info = new DirectoryInfo(_options.Source);

                using (HashAlgorithm algorithm = HashAlgorithm.Create(_options.Algorithm))
                {
                    RunOnDirectory(info, algorithm);

                    if (!_options.Recursive)
                    {
                        return;
                    }

                    foreach (DirectoryInfo directoryInfo in info.EnumerateDirectories("*", SearchOption.AllDirectories))
                    {
                        RunOnDirectory(directoryInfo, algorithm);
                    }
                }
            }
            else
            {
                FileInfo fileInfo = new FileInfo(_options.Source);

                if (!fileInfo.Exists)
                {
                    return;
                }

                using (HashAlgorithm algorithm = HashAlgorithm.Create(_options.Algorithm))
                {
                    RunOnFile(fileInfo, algorithm, CreateFinalDirectoryPath(fileInfo.Directory));
                }
            }
        }