예제 #1
0
        /// <summary>
        /// Parses the passed command line arguments, handles if a batch job was specified,
        /// runs the deletion operation. Main entry point for the class.
        /// </summary>
        /// <param name="path">0th argument passed in (file or folder to delete)</param>
        /// <param name="cla">The structured command line arguments</param>
        public static void Run(string path, CommandLineArgs cla)
        {
            _ca = new CompletionAction();

            // First, parse the command line arguments and assign them to varibles
            ParseArgs(cla);

            // If we aren't running a batch job...
            if (!_batch)
            {
                Target target = new Target(path);

                // If the target exists
                if (target.Exists)
                {
                    // Try deleting the target
                    try
                    {
                        DeletionOps.MultithreadingSetup mt = new DeletionOps.MultithreadingSetup(_multithreading, _numThreads);
                        DeletionOps.Logging log = new DeletionOps.Logging(_logging, _logTo);
                        _error = DeletionOps.Delete(target, mt, log, !_quiet);
                    }
                    catch (Exception ex)
                    {
                        // If the user specifies quiet mode, don't display exception
                        if (!_quiet)
                            Console.WriteLine(ex.ToString());
                        _error = 1;
                    }
                    finally
                    {
                        // If it was a success
                        if (_error == 0)
                        {
                            CleanupDirectory(target);

                            // No command is specified, run the completion action
                            if (string.IsNullOrEmpty(_command))
                                _ca.Run(false, _forceAction);
                            // Otherwise, run the custom command
                            else if (!string.IsNullOrEmpty(_command))
                                RunCommand();
                        }
                    }
                }
                // If the target doesn't exist and we're not in quiet mode, write the error
                else if (!target.Exists && !_quiet)
                    Console.WriteLine(SharedResources.Properties.Resources.TargetNotFound);
            }
            else
            {
                // If the user passed a job file and it exists, execute it
                if (File.Exists(_jobFile))
                    RunJobDeletion();
                // Otherwise display an error
                else
                    if (!_quiet) Console.WriteLine(SharedResources.Properties.Resources.JobFileNotFound);
            }
        }
예제 #2
0
파일: Main.cs 프로젝트: z0civic/filexile
	    /// <summary>
		/// Sets up the Multithreading and Logging structs based on the control configurations and begins the deletion operation
		/// </summary>
		private void RunDeletion()
		{
			var mt = new DeletionOps.MultithreadingSetup(true, 8);
			var log = new DeletionOps.Logging(false, "");
			DeletionOps.Delete(_target, mt, log, false);
		}
예제 #3
0
        /// <summary>
        /// Creates a StreamReader to parse the job file. Reads in each line as a separate file or directory
        /// to delete. 
        /// </summary>
        private static void RunJobDeletion()
        {
            StreamReader din = File.OpenText(_jobFile);
            string str;
            Target target = new Target();
            DeletionOps.MultithreadingSetup mt = new DeletionOps.MultithreadingSetup(_multithreading, _numThreads);
            DeletionOps.Logging log = new DeletionOps.Logging(_logging, _logTo);

            // While there are still more lines to read and no errors have been encountered
            while (!string.IsNullOrEmpty((str = din.ReadLine())) && _error == 0)
            {
                // Set the target's path based on the line
                target.Path = str;
                // Run the deletion
                _error = DeletionOps.Delete(target, mt, log, !_quiet);
            }
        }
예제 #4
0
파일: Main.cs 프로젝트: z0civic/filexile
	    /// <summary>
        /// Sets up the Multithreading and Logging structs based on the control configurations and begins the deletion operation
        /// </summary>
        private void RunDeletion()
        {
            var mt = new DeletionOps.MultithreadingSetup(MultiThreadingEnabled, ThreadCount);
            var log = new DeletionOps.Logging(LoggingEnabled, LogTo);
            DeletionOps.Delete(_target, mt, log, ShowOutput);
        }