1
0
mirror of synced 2025-02-17 11:18:33 +01:00

trying to change gzip compressor

This commit is contained in:
NotImplementedLife 2023-09-18 19:51:03 +03:00
parent 0cc23812da
commit b3bb2d1312
2 changed files with 24 additions and 1 deletions

19
GZ.cs
View File

@ -1,6 +1,9 @@
using ICSharpCode.SharpZipLib.Tar; using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Tar;
using System.Diagnostics; using System.Diagnostics;
using System.IO.Compression; using System.IO.Compression;
using System.Text;
using static System.Net.Mime.MediaTypeNames;
namespace TaikoSoundEditor namespace TaikoSoundEditor
{ {
@ -57,6 +60,20 @@ namespace TaikoSoundEditor
{ {
Logger.Info("GZ Compressing file"); Logger.Info("GZ Compressing file");
var uncompressed = Encoding.UTF8.GetBytes(content);
using (MemoryStream outStream = new MemoryStream())
{
using (GZipOutputStream gzoStream = new GZipOutputStream(outStream))
{
gzoStream.SetLevel(5);
gzoStream.Write(uncompressed, 0, uncompressed.Length);
}
File.WriteAllBytes(fileName, outStream.ToArray());
}
return "";
var tmp = "~ztmp"; var tmp = "~ztmp";
if (!Directory.Exists(tmp)) if (!Directory.Exists(tmp))
Directory.CreateDirectory(tmp); Directory.CreateDirectory(tmp);

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -14,7 +15,12 @@ namespace TaikoSoundEditor.Utils
public T Deserialize<T>(string path) public T Deserialize<T>(string path)
{ {
if (!IsEncrypted) if (!IsEncrypted)
{
var str = GZ.DecompressString(path);
Debug.WriteLine("----------------------------------------------------------------------");
Debug.WriteLine(str);
return Json.Deserialize<T>(GZ.DecompressString(path)); return Json.Deserialize<T>(GZ.DecompressString(path));
}
else else
{ {
var bytes = SSL.DecryptDatatable(File.ReadAllBytes(path)); var bytes = SSL.DecryptDatatable(File.ReadAllBytes(path));