static void maybeExtractZIPFile(string _zipPath, string _destPath)
 {
     if (File.Exists(_zipPath))
     {
         using (ZipArchive myZipArchive = ZipFile.OpenRead(_zipPath)){
             if (Options.simpleConsoleOutput)
             {
                 Console.Out.WriteLine("[EXTRACT] {0} to {1}", _zipPath, _destPath);
             }
             try{
                 myZipArchive.ExtractToDirectory(_destPath, true);
             }catch (Exception e) {
                 Console.Out.WriteLine("Error extracting ZIP file.");
                 Console.Out.WriteLine(e.ToString());
                 if (StolenCode.IsRunningOnMono())
                 {
                     Console.Out.WriteLine("=============");
                     Console.Out.WriteLine("Please make sure Mono is updated if it's not already.");
                 }
                 printPressAnyKey();
                 Console.ReadKey();
                 Environment.Exit(1);
             }
         }
     }
     else
     {
         if (Options.simpleConsoleOutput)
         {
             Console.Out.WriteLine("[NOT EXTRACT] {0} not exist.", _zipPath);
         }
     }
 }
        static bool getFFmpegExist()
        {
            Process _possibleFFmpegProcess = new Process();

            if (StolenCode.IsRunningOnMono())
            {
                _possibleFFmpegProcess.StartInfo.FileName = "ffmpeg";
            }
            else
            {
                _possibleFFmpegProcess.StartInfo.FileName = "ffmpeg.exe";
            }
            _possibleFFmpegProcess.StartInfo.Arguments              = "-version";
            _possibleFFmpegProcess.StartInfo.UseShellExecute        = false;
            _possibleFFmpegProcess.StartInfo.RedirectStandardOutput = true;
            try{
                _possibleFFmpegProcess.Start();
                _possibleFFmpegProcess.WaitForExit();
            }catch (Exception) {           // Windows throws error if file not found
                return(false);
            }
            if (_possibleFFmpegProcess.StandardOutput.ReadToEnd().StartsWith("ffmpeg version"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 static void _convertSingleSound(string _inFile)
 {
     if (Path.GetExtension(_inFile) == ".aac")
     {
         if (Options.canUseFFmpeg)
         {
             if (Options.detailedConsoleOutput)
             {
                 Console.Out.WriteLine("Process {0}", _inFile);
             }
             Process _FFmpegProcess = new Process();
             if (StolenCode.IsRunningOnMono())
             {
                 _FFmpegProcess.StartInfo.FileName = "ffmpeg";
             }
             else
             {
                 _FFmpegProcess.StartInfo.FileName = "ffmpeg.exe";
             }
             _FFmpegProcess.StartInfo.Arguments              = "-i \"" + _inFile + "\" \"" + Path.ChangeExtension(_inFile, ".ogg") + "\"";
             _FFmpegProcess.StartInfo.UseShellExecute        = false;
             _FFmpegProcess.StartInfo.RedirectStandardOutput = true;
             _FFmpegProcess.Start();
             if (!Options.canInfiniteProcess)
             {
                 // Don't want my users' computers to explode
                 _FFmpegProcess.WaitForExit(3000);
             }
         }
         else
         {
             if (Options.errorConsoleOutput)                      // Because this is important
             {
                 Console.Out.WriteLine("Skip .aac file {0}", _inFile);
             }
         }
     }
 }
        static void Main(string[] args)
        {
            string _sourceFile = null;

            Console.Out.Write("Checking for FFmpeg...");
            Options.canUseFFmpeg = getFFmpegExist();
            Console.Out.WriteLine(Options.canUseFFmpeg);

            Console.Out.WriteLine("Write v" + Options.writtenVersionNumber);
            if (args.Length == 0)
            {
                if (!StolenCode.IsRunningOnMono())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    MainForm myMainForm = new MainForm();
                    Application.Run(myMainForm);
                    _sourceFile = myMainForm.confirmedChosenDirectory;
                    if (_sourceFile == null)
                    {
                        Console.Out.WriteLine("_sourceFile==null");
                        return;
                    }
                }
                else
                {
                    args    = new string[1];
                    args[0] = null;

                    if (!Options.canUseFFmpeg)
                    {
                        Console.Out.WriteLine("\n\nI think FFmpeg is not installed. AAC audio won't be able to be converted and played on the Vita. If you want this feature, please install FFmpeg and make sure it's in PATH. Run from terminal and append -forceffmpeg to force FFmpeg usage even if it's not found. \n\n");
                    }

                    while (args[0] == null)
                    {
                        Console.Out.WriteLine("Enter the VNDS game's folder path. The path should end in a slash and the folder should be in a writable directory\nFor example, /home/nathan/higurashi/\n");
                        args[0] = Console.ReadLine();
                        if (!Directory.Exists(args[0]))
                        {
                            Console.Out.WriteLine("\nDirectory {0} does not exist.", args[0]);
                            args[0] = null;
                        }
                    }

                    // Platform prompt
                    do
                    {
                        Console.Out.WriteLine("\n\nEnter the number of the platform you want to convert for.\n");
                        for (int j = 0; j < Options.possiblePlatforms.Length; ++j)
                        {
                            Console.Out.WriteLine("{0}) {1}", j, Options.possiblePlatforms[j]);
                        }

                        int _userSelection;
                        if (Int32.TryParse(Console.ReadLine(), out _userSelection))
                        {
                            Options.applyPlatformPresent(Options.possiblePlatforms[_userSelection]);
                        }
                        else
                        {
                            Console.Out.WriteLine("User input was not a nu- wait a second, this isn't in Windows mode. I expected more from you.");
                        }
                    }while(Options.platformName == null);
                }
            }
            int i;

            for (i = 0; i < args.Length; i++)
            {
                if (args[i][0] != '-')
                {
                    _sourceFile = args[i];
                }
                else
                {
                    if (args[i] == "-simpleoutput")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.simpleConsoleOutput);
                    }
                    else if (args[i] == "-detailedoutput")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.detailedConsoleOutput);
                    }
                    else if (args[i] == "-erroroutput")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.errorConsoleOutput);
                    }
                    else if (args[i] == "-importantoutput")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.importantConsoleOutput);
                    }
                    else if (args[i] == "-autodelete")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.autoDelete);
                    }
                    else if (args[i] == "-ffmpeg")
                    {
                        toggleDependingOnArgs(args, ref i, ref Options.canUseFFmpeg);
                    }
                    else if (args[i] == "-forceffmpeg")
                    {
                        Options.canUseFFmpeg = true;
                    }
                    else if (args[i] == "-infiniteprocesses")
                    {
                        Options.canInfiniteProcess = true;
                    }
                }
            }
            if (_sourceFile == null)
            {
                if (Options.importantConsoleOutput)
                {
                    Console.Out.WriteLine("No path found. Make sure your path doesn't start with a hyphen.");
                    printPressAnyKey();
                }
                Console.ReadKey();
                return;
            }
            if (!File.Exists(Path.Combine(_sourceFile, "info.txt")))
            {
                Console.Out.WriteLine("{0} does not exist, so I assume that this IS NOT a VNDS game folder. Retry.\n", Path.Combine(_sourceFile, "info.txt"));
                return;
            }

            //for (i=0;i<possibleFreacLocations.Length;++i){
            //	if (File.Exists(possibleFreacLocations[i])){
            //		Options.canConvertAudio=true;
            //		Options.actualFreacLocation = possibleFreacLocations[i];
            //		break;
            //	}
            //}
            //if (!Options.canConvertAudio){
            //	Console.out.WriteLine("This is the version without audio conversion. DS novels may not convert correctly.");
            //}

            if (Options.importantConsoleOutput)
            {
                Console.WriteLine("Hello World!");
            }
            // TODO: Implement Functionality Here
            if (Options.importantConsoleOutput)
            {
                Console.Out.WriteLine("Done, you may close this window.\nThe converted game is at {0}", doFunctionality(_sourceFile));
                printPressAnyKey();
                Console.ReadKey(true);
            }
            else
            {
                doFunctionality(_sourceFile);
            }
        }