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); }
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(); } } } }
public void GetDirectoryTest(string path) { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk")); IGgpkDirectory dir = archive.GetDirectory(path); Assert.AreEqual(2, dir.Files.Count()); }
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); }
public void GetFileTest(string path) { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk")); IGgpkFile file = archive.GetFile(path); Assert.AreEqual(4UL, file.Length); }
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()); }
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); } }
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); }
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); }
public void GetFileDirectoryNotFoundTest() { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk")); IGgpkFile file = archive.GetFile("/NonExistingDirectory/test-file-1.bin"); }
public void FromFileNullTest() { GgpkArchive archive = GgpkArchive.From((FileInfo)null); }
public void FromStringNotExistsTest() { GgpkArchive archive = GgpkArchive.From(@"C:\i_do_not_exist.test"); }
public void FromStringNullTest() { GgpkArchive archive = GgpkArchive.From((string)null); }
public void GetDirectoryNotFoundTest() { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk")); IGgpkDirectory dir = archive.GetDirectory("/NonExistingDirectory/"); }
public void GetFileNotFoundTest() { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"pass.ggpk")); IGgpkFile file = archive.GetFile("/Dir_1/i_do_not_exist.non"); }
static void Main(string[] args) { GgpkArchive archive = GgpkArchive.From(Path.Combine(Environment.GetEnvironmentVariable("POE_PATH"), "content.ggpk")); PrintDirectory(archive.Root); }
public void FromFileNotExistsTest() { GgpkArchive archive = GgpkArchive.From(new FileInfo(@"C:\i_do_not_exist.test")); }
/// <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(); }