Esempio n. 1
0
        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"));
     }
 }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
        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());
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
 }