Ejemplo n.º 1
0
        /// <summary>
        /// Execute cleaning of files/directories.
        /// Doesn't actually delete anything but generates a file
        /// containing the commands.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override BoolMessageItem  Execute(object context)
        {
            FileCleanArgs args = Settings.ArgsReciever as FileCleanArgs;

            // Initialize the starting directory.
            InitializeDir(args.RootDir);

            StringBuilder buffer      = new StringBuilder();
            bool          handleFiles = true;

            if (args.FileType == "dir")
            {
                handleFiles = false;
            }

            FileSearcher searcher = new FileSearcher(new Action <FileInfo>(HandleFile), new Action <DirectoryInfo>(HandleDirectory), "**/**", handleFiles);

            searcher.Search(_rootDirectory);
            File.WriteAllText(args.OutputFile, _buffer.ToString());
            return(new BoolMessageItem(null, true, string.Empty));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute cleaning of files/directories.
        /// Doesn't actually delete anything but generates a file
        /// containing the commands.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public override BoolMessageItem  Execute(object context)
        {
            // Initialize the starting directory.
            InitializeDir(_args.RootDir);

            StringBuilder buffer      = new StringBuilder();
            bool          handleFiles = true;

            if (_args.FileType == "dir")
            {
                handleFiles = false;
            }

            _license = File.ReadAllText(_args.LicenseFile);
            FileSearcher searcher = new FileSearcher(new Action <FileInfo>(HandleFile), new Action <DirectoryInfo>(HandleDirectory), _args.Pattern, handleFiles);

            searcher.Init();
            searcher.Search(_rootDirectory);
            File.WriteAllText(_args.OutputFile, _buffer.ToString());
            return(new BoolMessageItem(null, true, string.Empty));
        }