Beispiel #1
0
    private static void ProcessSinglePxdFile(string argPath, Pxd32Library lib)
    {
        // it can be already wav file
        if (Encoding.ASCII.GetString(ReadFileFromTo(argPath, 0, 4)) == "RIFF")
        {
            var dir = $"{Directory.GetCurrentDirectory()}\\converted_wav_files\\";
            Directory.CreateDirectory(dir);
            var filePath = $"{dir}{Path.GetFileNameWithoutExtension(argPath)}.wav";

            if (!File.Exists(filePath))
            {
                File.Copy(argPath, filePath);
            }
        }
        else
        {
            Console.WriteLine($"Converting raw data file {argPath} to wav format...");

            var tmpPath = TmpPath + "tmp.wav";

            lib.Decompress(argPath, tmpPath);

            RawToWav(argPath, tmpPath);
        }
    }
Beispiel #2
0
    private static void Main(string[] args)
    {
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("         _           ___");
        Console.WriteLine("  ___ _ | |__ _ _  _|   \\ ___ __ ___ _ __  _ __ _ _ ___ ______ ___ _ _");
        Console.WriteLine(" / -_) || / _` | || | |) / -_) _/ _ \\ '  \\| '_ \\ '_/ -_|_-<_-</ _ \\ '_|");
        Console.WriteLine(" \\___|\\__/\\__,_|\\_, |___/\\___\\__\\___/_|_|_| .__/_| \\___/__/__/\\___/_|");
        Console.WriteLine("                |__/                      |_|\n");
        Console.WriteLine("Version 1.3");
        Console.ResetColor();


        if (args.Length < 1)
        {
            Console.WriteLine("You need at least 1 argument to run this program: PXD file path.");
            Console.WriteLine("If you wish to convert multiple files at once, please use -all argument.");

            Console.WriteLine("\nUSAGE:\n");

            Console.WriteLine("./eJayDecompressor.exe <pxd_file_location>");
            Console.WriteLine("./eJayDecompressor.exe -all <folder_location>\n" +
                              "Note: If <folder_location> is not specified, the program will try to use the path where the program " +
                              "was executed.");

            Environment.Exit(-1);
        }

        var argPath         = string.Empty;
        var recursiveSearch = false;

        if (args[0].Equals("-all"))
        {
            recursiveSearch = true;

            if (args.Length == 2)
            {
                argPath = args[1];
            }
        }
        else
        {
            argPath = args[0];
        }

        argPath = argPath.Trim();

        Directory.CreateDirectory("converted_wav_files");

        //buffer used by .dll
        Directory.CreateDirectory(TmpPath);

        if (recursiveSearch)
        {
            FindFilesToDecompress(argPath);
        }
        else
        {
            if (argPath.EndsWith(".pxd"))
            {
                var lib = new Pxd32Library();
                Pxd32Library.InitializeDll();
                ProcessSinglePxdFile(argPath, lib);
                Pxd32Library.CloseDll();
            }
            else if (argPath.EndsWith("inf.bin"))
            {
                ProcessMultiWithBinaryInf(argPath, new EjToolLibrary());
            }
            else if (argPath.EndsWith(".inf"))
            {
                ProcessMultiWithTextInf(argPath, new EjToolLibrary());
            }
            else if (argPath.EndsWith(".scl"))
            {
                SclToWav(argPath);
            }
            else
            {
                Console.WriteLine("You should pass only *.PXD, *inf.bin and .inf files");
            }
        }

        Directory.Delete(TmpPath, true);

        Console.WriteLine("Finished.");
    }