Beispiel #1
0
        public void TestFullName()
        {
            GgpkArchive    archive = GgpkArchive.From(@"pass.ggpk");
            IGgpkDirectory dir     = archive.Root.Directories.Where(d => d.Name == "Dir_1").FirstOrDefault();

            Assert.AreEqual("/Dir_1/", dir.FullName);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string sourceFile           = Path.Combine(Environment.GetEnvironmentVariable("POE_PATH"), "content.ggpk");
            string destinationDirectory = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "content-ggpk");

            GgpkArchive             archive = GgpkArchive.From(sourceFile);
            IEnumerable <IGgpkFile> files   = archive.Root.ToFileList();

            foreach (var file in files)
            {
                string destinationFileName = Path.Combine(destinationDirectory, file.FullName.Replace('/', '\\').Substring(1));

                Directory.CreateDirectory(new FileInfo(destinationFileName).DirectoryName);

                using (BinaryWriter destinationFileWriter = new BinaryWriter(File.Create(destinationFileName)))
                {
                    using (BinaryReader sourceFileReader = new BinaryReader(file.GetStream()))
                    {
                        Console.WriteLine($"Extracting {file.FullName}...");

                        destinationFileWriter.Write(sourceFileReader.ReadBytes((int)file.Length));
                        destinationFileWriter.Flush();
                    }
                }
            }
        }
Beispiel #3
0
        public void GetDirectoryTest(string path)
        {
            GgpkArchive    archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));
            IGgpkDirectory dir     = archive.GetDirectory(path);

            Assert.AreEqual(2, dir.Files.Count());
        }
Beispiel #4
0
        public void TestFullName()
        {
            GgpkArchive archive = GgpkArchive.From(@"pass.ggpk");
            IGgpkFile   file    = archive.Root.Directories.Where(d => d.Name == "Dir_1").FirstOrDefault().Files.Where(f => f.Name == "Aa_Bb-Cc.DdEe").FirstOrDefault();

            Assert.AreEqual("/Dir_1/Aa_Bb-Cc.DdEe", file.FullName);
        }
Beispiel #5
0
        public void GetFileTest(string path)
        {
            GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));
            IGgpkFile   file    = archive.GetFile(path);

            Assert.AreEqual(4UL, file.Length);
        }
Beispiel #6
0
        public void ToFileListTest()
        {
            GgpkArchive             archive  = GgpkArchive.From(@"pass.ggpk");
            IEnumerable <IGgpkFile> allFiles = archive.Root.ToFileList();

            Assert.AreEqual(2, allFiles.Count());
            Assert.IsNotNull(allFiles.Where(f => f.Name == "test-file-1.bin").FirstOrDefault());
            Assert.IsNotNull(allFiles.Where(f => f.Name == "Aa_Bb-Cc.DdEe").FirstOrDefault());
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            GgpkArchive             archive  = GgpkArchive.From(Path.Combine(Environment.GetEnvironmentVariable("POE_PATH"), "content.ggpk"));
            IEnumerable <IGgpkFile> allFiles = archive.Root.ToFileList();

            foreach (var file in allFiles)
            {
                Console.WriteLine(file.FullName);
            }
        }
Beispiel #8
0
        public void FromTest()
        {
            GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));

            Assert.AreEqual <int>(1, archive.Root.Directories.Count());

            IGgpkDirectory dir1 = archive.Root.Directories.FirstOrDefault();

            Assert.AreEqual("Dir_1", dir1.Name);

            IGgpkFile file1 = dir1.Files.Where(f => f.Name == "test-file-1.bin").FirstOrDefault();
            IGgpkFile file2 = dir1.Files.Where(f => f.Name == "Aa_Bb-Cc.DdEe").FirstOrDefault();

            Assert.IsNotNull(file1);
            Assert.IsNotNull(file2);

            Assert.AreEqual <ulong>(4, file1.Length);

            Assert.IsNull(archive.Root.Parent);
            Assert.IsNotNull(dir1.Parent);
            Assert.IsNotNull(file1.Parent);
            Assert.IsNotNull(file2.Parent);
        }
Beispiel #9
0
        public void TestArchive()
        {
            string poePath = Environment.GetEnvironmentVariable("POE_PATH");

            if (string.IsNullOrEmpty(poePath))
            {
                Assert.Inconclusive("Environment variable POE_PATH not defined - skipping test");
            }

            string contentFile = Path.Combine(poePath, "content.ggpk");

            if (!File.Exists(contentFile))
            {
                Assert.Inconclusive("content.ggpk not found - skipping test");
            }

            GgpkArchive archive = GgpkArchive.From(contentFile);

            Assert.IsNotNull(archive.Root);

            IEnumerable <IGgpkFile> files = archive.Root.ToFileList();

            foreach (var file in files)
            {
                StringAssert.StartsWith(file.FullName, "/");
                Assert.AreEqual(false, file.FullName.Contains('\\', StringComparison.InvariantCultureIgnoreCase));
            }

            IGgpkDirectory dialogueDirectory = archive.GetDirectory("/Audio/Dialogue/");

            Assert.IsNotNull(dialogueDirectory);

            IGgpkFile noAudioFoundFile = archive.GetFile("/Audio/NoFileFound.ogg");

            Assert.IsNotNull(noAudioFoundFile);
        }
Beispiel #10
0
 public void GetFileDirectoryNotFoundTest()
 {
     GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));
     IGgpkFile   file    = archive.GetFile("/NonExistingDirectory/test-file-1.bin");
 }
Beispiel #11
0
 public void FromFileNullTest()
 {
     GgpkArchive archive = GgpkArchive.From((FileInfo)null);
 }
Beispiel #12
0
 public void FromStringNotExistsTest()
 {
     GgpkArchive archive = GgpkArchive.From(@"C:\i_do_not_exist.test");
 }
Beispiel #13
0
 public void FromStringNullTest()
 {
     GgpkArchive archive = GgpkArchive.From((string)null);
 }
Beispiel #14
0
 public void GetDirectoryNotFoundTest()
 {
     GgpkArchive    archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));
     IGgpkDirectory dir     = archive.GetDirectory("/NonExistingDirectory/");
 }
Beispiel #15
0
 public void GetFileNotFoundTest()
 {
     GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk"));
     IGgpkFile   file    = archive.GetFile("/Dir_1/i_do_not_exist.non");
 }
Beispiel #16
0
        static void Main(string[] args)
        {
            GgpkArchive archive = GgpkArchive.From(Path.Combine(Environment.GetEnvironmentVariable("POE_PATH"), "content.ggpk"));

            PrintDirectory(archive.Root);
        }
Beispiel #17
0
 public void FromFileNotExistsTest()
 {
     GgpkArchive archive = GgpkArchive.From(new FileInfo(@"C:\i_do_not_exist.test"));
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GgpkStreamTests"/> class.
 /// </summary>
 public GgpkStreamTests()
 {
     this.archive = GgpkArchive.From(@"pass.ggpk");
     this.file    = this.archive.Root.Directories.Where(d => d.Name == "Dir_1").FirstOrDefault().Files.Where(f => f.Name == "Aa_Bb-Cc.DdEe").FirstOrDefault();
 }