예제 #1
0
        /// <summary>
        /// Main program - determines arguments if they need to be processed as a list or not for File Object creations
        /// </summary>
        /// <param name="argument">The arguments.</param>
        public void process(string[] argument)
        {
            bool bIsDirectory;
              string fullpath;

              ListProcessor processList = new ListProcessor();
              List<string> argList = new List<string>();

              List<string> filteredArgs = new List<string>();

              progressState.progressPercent = 0;

              foreach (string arg in argument)
              {
            /*
             * Temporary workaround for empty strings
             * For now, it should be "safe" for arguments passed from the GUI.
             * arguments normally should not contain empty strings
             *
             */
            if (!string.IsNullOrEmpty(arg))
            {
              //FileObject file = new FileObject(arg);
              fullpath = Path.GetFullPath(arg);

              //Initiliaze attribute checker
              FileAttributes attr = File.GetAttributes(fullpath);

              //Determine if provided path is a directory or a file
              if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
            bIsDirectory = true;
              else
            bIsDirectory = false;

              //If it's a file, add it to a fileList, if not, process it as a fileList
              if (bIsDirectory == false)
              {
            argList.Add(arg);
            filteredArgs.Add(arg);
              }
              else
              {

              //Update percentage of the arguments processed. Used for GUI.

            processPercent = progress.ToPercentage(argument.Length);

            progressArg = processPercent;

            Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

            List<string> folderFiles = new List<string>();

            foreach (string extension in MediaData.extensions)
              foreach (string folderFile in Directory.GetFiles(fullpath, "*" + extension))
              {
                folderFiles.Add(folderFile);
                filteredArgs.Add(folderFile);
              }

            processList.processList(folderFiles, Path.GetFileNameWithoutExtension(arg), this, fullpath, argument.Length);

            progress++;

              }

            }

              }

            //for individual files: process the built list after foreach loop
              if (argList.Count > 0)
              {

            processPercent = 100;

            progressArg = processPercent;

            Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

            processList.processList(argList, "various files", this, Program.defaultPath);

              }

              if (filteredArgs.Count > 0)
              {
            //AnalyzeList(filteredArgs);
              }
        }
예제 #2
0
        /// <summary>
        /// Main program - determines arguments if they need to be processed as a list or not for File Object creations
        /// </summary>
        /// <param name="argument">The arguments.</param>
        public void process(string[] argument)
        {
            bool   bIsDirectory;
            string fullpath;

            ListProcessor processList = new ListProcessor();
            List <string> argList     = new List <string>();

            List <string> filteredArgs = new List <string>();

            progressState.progressPercent = 0;


            foreach (string arg in argument)
            {
                /*
                 * Temporary workaround for empty strings
                 * For now, it should be "safe" for arguments passed from the GUI.
                 * arguments normally should not contain empty strings
                 *
                 */
                if (!string.IsNullOrEmpty(arg))
                {
                    //FileObject file = new FileObject(arg);
                    fullpath = Path.GetFullPath(arg);

                    //Initiliaze attribute checker
                    FileAttributes attr = File.GetAttributes(fullpath);

                    //Determine if provided path is a directory or a file
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        bIsDirectory = true;
                    }
                    else
                    {
                        bIsDirectory = false;
                    }

                    //If it's a file, add it to a fileList, if not, process it as a fileList
                    if (bIsDirectory == false)
                    {
                        argList.Add(arg);
                        filteredArgs.Add(arg);
                    }
                    else
                    {
                        //Update percentage of the arguments processed. Used for GUI.

                        processPercent = progress.ToPercentage(argument.Length);

                        progressArg = processPercent;

                        Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

                        List <string> folderFiles = new List <string>();

                        foreach (string extension in MediaData.extensions)
                        {
                            foreach (string folderFile in Directory.GetFiles(fullpath, "*" + extension))
                            {
                                folderFiles.Add(folderFile);
                                filteredArgs.Add(folderFile);
                            }
                        }

                        processList.processList(folderFiles, Path.GetFileNameWithoutExtension(arg), this, fullpath, argument.Length);

                        progress++;
                    }
                }
            }

            //for individual files: process the built list after foreach loop
            if (argList.Count > 0)
            {
                processPercent = 100;

                progressArg = processPercent;

                Analyze.backgroundWorker.ReportProgress(progressArg, progressState);

                processList.processList(argList, "various files", this, Program.defaultPath);
            }


            if (filteredArgs.Count > 0)
            {
                //AnalyzeList(filteredArgs);
            }
        }