Fix file.gzip
This commit is contained in:
parent
209479be46
commit
516e62eade
@ -189,30 +189,26 @@ static int l_list(lua::State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int l_gzip_compress(lua::State* L) {
|
static int l_gzip_compress(lua::State* L) {
|
||||||
std::vector<ubyte> bytes;
|
auto string = lua::bytearray_as_string(L, 1);
|
||||||
|
|
||||||
lua::read_bytes_from_table(L, 1, bytes);
|
auto compressedBytes = gzip::compress(
|
||||||
auto compressed_bytes = gzip::compress(bytes.data(), bytes.size());
|
reinterpret_cast<const ubyte*>(string.data()),
|
||||||
int newTable = lua::gettop(L);
|
string.size()
|
||||||
|
);
|
||||||
|
|
||||||
for (size_t i = 0; i < compressed_bytes.size(); i++) {
|
lua::create_bytearray(L, std::move(compressedBytes));
|
||||||
lua::pushinteger(L, compressed_bytes.data()[i]);
|
|
||||||
lua::rawseti(L, i + 1, newTable);
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_gzip_decompress(lua::State* L) {
|
static int l_gzip_decompress(lua::State* L) {
|
||||||
std::vector<ubyte> bytes;
|
auto string = lua::bytearray_as_string(L, 1);
|
||||||
|
|
||||||
lua::read_bytes_from_table(L, 1, bytes);
|
auto decompressedBytes = gzip::decompress(
|
||||||
auto decompressed_bytes = gzip::decompress(bytes.data(), bytes.size());
|
reinterpret_cast<const ubyte*>(string.data()),
|
||||||
int newTable = lua::gettop(L);
|
string.size()
|
||||||
|
);
|
||||||
|
|
||||||
for (size_t i = 0; i < decompressed_bytes.size(); i++) {
|
lua::create_bytearray(L, std::move(decompressedBytes));
|
||||||
lua::pushinteger(L, decompressed_bytes.data()[i]);
|
|
||||||
lua::rawseti(L, i + 1, newTable);
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user