Esempio n. 1
0
        internal static async Task <int> UnpackPak(FileInfo fileInfo, string outputDirectory, bool showContentInfo = false)
        {
            try
            {
                PakFile pak = PakFile.Open(fileInfo);

                if (showContentInfo)
                {
                    CliUtilities.PrintRow("File", "FileSize");
                    ShowPakInfo(pak);
                    Console.WriteLine();
                }

                Console.WriteLine($"Total file count {pak.FileCount} \n");

                bool unpack = CliUtilities.ShowConsolePrompt($"Do you want to unpack {fileInfo.Name}");

                if (unpack)
                {
                    await Unpack(pak, outputDirectory);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(1);
            }
            return(0);
        }
Esempio n. 2
0
        private static void ShowPakInfo(PakFile pak)
        {
            try
            {
                string[] fileNames = pak.AbsoluteIndex.Select(f => f.Value.FileName).ToArray();
                string[] fileSizes = pak.AbsoluteIndex.Select(f => f.Value.UncompressedSize.ToString()).ToArray();

                foreach (KeyValuePair <string, PakEntry> pakDict in pak.AbsoluteIndex)
                {
                    var name = pakDict.Value.FileName;
                    var size = pakDict.Value.UncompressedSize.ToString();

                    CliUtilities.PrintLine();
                    CliUtilities.PrintRow(name, size);
                }
                CliUtilities.PrintLine();
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        internal static async Task <int> UnpackPaks(string inputDirectory, string outputDirectory)
        {
            try
            {
                IEnumerable <string> files = Directory.EnumerateFiles(inputDirectory);

                bool unpack = CliUtilities.ShowConsolePrompt($"Do you want to unpack {files.Count()} files?");

                if (unpack)
                {
                    using (ProgressBar pbar = new ProgressBar(files.Count(), "", pbarOptions))
                    {
                        foreach (var file in files)
                        {
                            FileInfo info = new FileInfo(file);
                            PakFile  pak  = await PakFile.OpenAsync(info);

                            using (ChildProgressBar childPbar = pbar.Spawn(pak.FileCount, "", pbarOptions))
                            {
                                await UnpackDirectory(pak, outputDirectory, childPbar.AsProgress <PakEntry>(e => e.FileName));

                                pbar.Tick();
                            }
                        }
                    }

                    Console.WriteLine("Unpack completed!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(1);
            }
            return(0);
        }