summaryrefslogtreecommitdiffhomepage
path: root/Public
diff options
context:
space:
mode:
Diffstat (limited to 'Public')
-rw-r--r--Public/SDK/ZipKit/Defines.hpp2
-rw-r--r--Public/SDK/ZipKit/NewFS-Addon.hpp2
-rw-r--r--Public/SDK/ZipKit/Zip.cpp32
-rw-r--r--Public/SDK/ZipKit/Zip.hpp49
4 files changed, 59 insertions, 26 deletions
diff --git a/Public/SDK/ZipKit/Defines.hpp b/Public/SDK/ZipKit/Defines.hpp
index 8f15dc6b..8c3790c6 100644
--- a/Public/SDK/ZipKit/Defines.hpp
+++ b/Public/SDK/ZipKit/Defines.hpp
@@ -11,4 +11,4 @@
#include <SystemKit/Defines.hpp>
-#define ZIPKIT_VERSION "1.0.0" \ No newline at end of file
+#define ZIPKIT_VERSION "1.0.1"
diff --git a/Public/SDK/ZipKit/NewFS-Addon.hpp b/Public/SDK/ZipKit/NewFS-Addon.hpp
index 07e41f64..4bc0c4c1 100644
--- a/Public/SDK/ZipKit/NewFS-Addon.hpp
+++ b/Public/SDK/ZipKit/NewFS-Addon.hpp
@@ -9,7 +9,7 @@
#pragma once
-// TODO: integrate MeFS compression.
+// TODO: integrate NewFS compression.
// MeFS catalog is compressed.
#define kCatalogFlagZip 255
diff --git a/Public/SDK/ZipKit/Zip.cpp b/Public/SDK/ZipKit/Zip.cpp
index e6ff73ad..a7b3e0f4 100644
--- a/Public/SDK/ZipKit/Zip.cpp
+++ b/Public/SDK/ZipKit/Zip.cpp
@@ -45,12 +45,42 @@ namespace ZipKit
void* ZipStream::Deflate(const char* name)
{
+ z_stream deflate_stream{ 0 };
- return nullptr;
+ deflate_stream.zalloc = Z_NULL;
+ deflate_stream.zfree = Z_NULL;
+ deflate_stream.opaque = Z_NULL;
+
+ // setup "b" as the input and "c" as the compressed output
+ deflate_stream.avail_in = (uInt)this->fSharedSz+1; // size of input, string + terminator
+ deflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
+ deflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
+ deflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
+
+ deflateInit(deflate_stream);
+ deflate(&deflate_stream, Z_NO_FLUSH);
+ deflateEnd(&deflate_stream);
+
+ return this->fSharedData;
}
void ZipStream::Inflate(const char* name, void* data)
{
+ z_stream inflate_stream{ 0 };
+
+ inflate_stream.zalloc = Z_NULL;
+ inflate_stream.zfree = Z_NULL;
+ inflate_stream.opaque = Z_NULL;
+
+ // setup "b" as the input and "c" as the compressed output
+ inflate_stream.avail_in = (uInt)((char*)inflate_stream.next_out - b); // size of input
+
+ inflate_stream.next_in = (Bytef *)this->fSharedData; // input char array
+ inflate_stream.avail_out = (uInt)this->fSharedSz; // size of output
+ inflate_stream.next_out = (Bytef *)this->fSharedData; // output char array
+ inflateInit(inflate_stream);
+ inflate(&inflate_stream, Z_NO_FLUSH);
+ inflateEnd(&inflate_stream);
}
} \ No newline at end of file
diff --git a/Public/SDK/ZipKit/Zip.hpp b/Public/SDK/ZipKit/Zip.hpp
index be7062f2..72105bc1 100644
--- a/Public/SDK/ZipKit/Zip.hpp
+++ b/Public/SDK/ZipKit/Zip.hpp
@@ -1,11 +1,11 @@
/*
- * ========================================================
- *
- * h-core
- * Copyright Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
+* ========================================================
+*
+* h-core
+* Copyright 2024 Mahrouss Logic, all rights reserved.
+*
+* ========================================================
+*/
#pragma once
@@ -18,25 +18,28 @@
namespace ZipKit
{
- class ZipStream;
+class ZipStream;
- class ZipStream final
- {
- public:
- explicit ZipStream();
- ~ZipStream() noexcept;
+class ZipStream final
+{
+ public:
+ explicit ZipStream();
+ ~ZipStream() noexcept;
+
+ public:
+ HCORE_COPY_DEFAULT(ZipStream);
- public:
- HCORE_COPY_DEFAULT(ZipStream);
+ public:
+ MeFilePtr FlushToFile(const char* name);
+ void* Deflate(const char* name);
+ void Inflate(const char* name, void* data);
- public:
- MeFilePtr FlushToFile(const char* name);
- void* Deflate(const char* name);
- void Inflate(const char* name, void* data);
+ private:
+ VoidStar fSharedData{ nullptr };
+ SizeT fSharedSz{ 0 };
- private:
- void* fSharedData{ nullptr };
- SizeT fSharedSz{ 0 };
+ private:
+ z_stream fStream;
- };
+};
}