public void ArchiveBuilderTest() { Cleanup(); EncryptedHalvaPackage package = new EncryptedHalvaPackage(sourceFolder, destinationArchive, testPassword); package.CloseArchive(); EncryptedPackageUtilities.ExportFromArchive(destinationArchive, destinationFolder, testPassword); }
/// <summary> /// Creates an encrypted Halva package in memory. This is used to update an archive or export some files. /// </summary> /// <param name="source">The archive you want to open.</param> /// <param name="pwsd">The password of the archive (if it's encrypted).</param> public EncryptedHalvaPackage(string source, string pwsd) { WorkingArchive = ReserveRandomArchive(); Password = pwsd; SourceLocation = new StringBuilder(Path.GetDirectoryName(source)); DestinationLocation = new StringBuilder(source); EncryptedPackageUtilities.DecompressArchive(DestinationLocation.ToString(), Password, WorkingArchive); ArchiveMemoryStream = ZipFile.Open(WorkingArchive, ZipArchiveMode.Update); PullFiles(ArchiveMemoryStream); }
private void ExtractPackage(string PackageName) { if (PackagePassword != "") { EncryptedPackageUtilities.ExportFromArchive(Path.Combine(PackageLocation, PackageName), Path.Combine(ExctractLocation, "GameData"), PackagePassword); } else { PackageUtilities.ExportFromArchive(Path.Combine(PackageLocation, PackageName), Path.Combine(ExctractLocation, "GameData")); } }
public void CanArchiveAddEntry() { EncryptedHalvaPackage package = new EncryptedHalvaPackage(destinationArchive, testPassword); package.AddFileToList(Path.Combine(sourceFolder, "TestImage.webp")); package.CloseArchive(); if (Directory.Exists(destinationFolder)) { Directory.Delete(destinationFolder, true); } EncryptedPackageUtilities.ExportFromArchive(destinationArchive, destinationFolder, testPassword); Assert.Equal(3, Directory.EnumerateFiles(destinationFolder).Count()); }
public void CanArchiveRemoveEntry() { EncryptedHalvaPackage package = new EncryptedHalvaPackage(destinationArchive, testPassword); package.RemoveFileFromList("TestImage.webp"); package.CloseArchive(); if (Directory.Exists(destinationFolder)) { Directory.Delete(destinationFolder, true); } EncryptedPackageUtilities.ExportFromArchive(destinationArchive, destinationFolder, testPassword); Assert.Equal(2, Directory.EnumerateFiles(destinationFolder).Count()); }
public void EncryptedDecompressionCheck() { bool finished = true; if (Directory.Exists("SampleFiles2")) { Directory.Delete("SampleFiles2", true); } try { EncryptedPackageUtilities.ExportFromArchive("EncryptedSampleFiles.halva", "SampleFiles2", "1234567890abcdefghijklm"); } catch (Exception e) { _testOutputHelper.WriteLine(e.ToString()); finished = false; } Assert.True(finished); }
public void EncryptedCompressionCheck() { bool finished = true; if (File.Exists("EncryptedSampleFiles.halva")) { File.Delete("EncryptedSampleFiles.halva"); } try { EncryptedPackageUtilities.CreateArchiveFromFolder("SampleFiles", "EncryptedSampleFiles.halva", "1234567890abcdefghijklm"); } catch (Exception e) { _testOutputHelper.WriteLine(e.ToString()); finished = false; } Assert.True(finished); }
/// <summary> /// Reloads the archive for editing. /// </summary> public void ReloadArchive() { EncryptedPackageUtilities.DecompressArchive(DestinationLocation.ToString(), Password); ArchiveMemoryStream = ZipFile.Open(PackageUtilities.TempArchive, ZipArchiveMode.Update); }
/// <summary> /// Closes the archive. /// </summary> public void CloseArchive() { ArchiveMemoryStream.Dispose(); EncryptedPackageUtilities.CompressArchive(WorkingArchive, DestinationLocation.ToString(), Password); }