예제 #1
0
        /// <summary>
        /// ToDo: update for new design
        /// Set an action based on user choice and perform action to specified file
        /// </summary>
        private async Task ProcessFile(string filePath)
        {
            if (!System.IO.Path.HasExtension(filePath))
            {
                Console.WriteLine("File does not have an extension!");
                mFileInfo.Update("Fail: has no extension");
                return;
            }

            // If verbose
            // Console.WriteLine("Processing File " + filePath + ":");
            mFileInfo.Init(filePath);

            // we don't need this var: IsSingleStaged anymore
            if (!IsSingleStaged)
            {
                foreach (CONVERTSTAGE stage in (CONVERTSTAGE[])Enum.GetValues(typeof(CONVERTSTAGE)))
                {
                    Stage = stage;
                    if (mFileInfo.IsInError)
                    {
                        break;
                    }

                    switch (Stage)
                    {
                    case CONVERTSTAGE.ExtractArchive:
                        ExtractRar(filePath);
                        break;

                    case CONVERTSTAGE.RenameFile:
                        RenameFile();
                        break;

                    case CONVERTSTAGE.ExtractMedia:
                        // accept containers containing subrip: currently only mkv
                        if (IsSupportedMedia(mFileInfo.Path) && (!ShouldSimulate || !mFileInfo.ModInfo.Contains("extract")))
                        {
                            // extract already checked for it
                            if (!mFileInfo.ModInfo.Contains("extract"))
                            {
                                HasEnoughFreeSpace((new System.IO.FileInfo(mFileInfo.Path)).Length);
                            }
                            if (mFileInfo.IsInError)
                            {
                                break;
                            }

                            var extractSub = new FFMpegUtil(ref mFileInfo);
                            mFileInfo = await extractSub.Run(ShouldSimulate);
                        }
                        break;

                    case CONVERTSTAGE.CreateArchive:
                        break;

                    default:
                        throw new InvalidOperationException("Invalid argument " + Stage + " to ProcessFile::switch");
                    }
                }
            }

            if (mFileInfo.IsInError)
            {
                FailedFileCount++;
            }
            else if (mFileInfo.IsModified)
            {
                ModifiedFileCount++;
            }
        }
예제 #2
0
        /// <summary>
        /// Props/methods related to single file processing
        /// <remarks>
        /// Member variable probably cannot be reference
        /// A solution is to pass this to methods
        /// </remarks>
        /// <c>code block inline example</c>
        ///
        /// Later, may be verify if found block contains property as well.
        /// Don't pass `filePath` as param, it is updated by rename and should be retrieved from FileInfo
        /// https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.useshellexecute
        /// </summary>

        public FFMpegUtil(ref FileInfoType fileInfo)
        {
            FFMpegPath            = @"D:\PFiles_x64\PT\ffmpeg";
            this.mFileInfo        = fileInfo;
            ShouldChangeContainer = true;
        }