summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-06 17:22:54 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-06 17:22:54 +0100
commit4467a6f5150c49cd0992a624c294018cf02be07c (patch)
treec0e8844ec2ee2cef40e9a0bfbbc229ab2b855c36 /luaotfload-database.lua
parent5c7df96b71cc281898067971ff96eb939f8d9d45 (diff)
downloadluaotfload-4467a6f5150c49cd0992a624c294018cf02be07c.tar.gz
[db] remove dependency on lualibs for compression
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua22
1 files changed, 17 insertions, 5 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index f103caa..567149a 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -31,6 +31,7 @@ local fontloaderinfo = fontloader.info
local fontloaderclose = fontloader.close
local fontloaderopen = fontloader.open
local fontloaderto_table = fontloader.to_table
+local gzipopen = gzip.open
local iolines = io.lines
local ioopen = io.open
local kpseexpand_path = kpse.expand_path
@@ -415,10 +416,13 @@ end
have to put our own small wrappers for the gzip library in
place.
+ load_gzipped -- Read and decompress and entire gzipped file.
+ Returns the uncompressed content as a string.
+
--doc]]--
local load_gzipped = function (filename)
- local gh = gzip.open (filename,"rb")
+ local gh = gzipopen (filename,"rb")
if gh then
local data = gh:read "*all"
gh:close ()
@@ -426,13 +430,21 @@ local load_gzipped = function (filename)
end
end
+--[[doc--
+
+ save_gzipped -- Compress and write a string to file. The return
+ value is the number of bytes written. Zlib parameters are: best
+ compression and default strategy.
+
+--doc]]--
+
local save_gzipped = function (filename, data)
- local gh = ioopen (filename, "wb")
+ local gh = gzipopen (filename, "wb9")
if gh then
- local bin = zlibcompress (data, 9, nil, 15 + 16)
- gh:write (bin)
+ gh:write (data)
+ local bytes = gh:seek ()
gh:close ()
- return #bin
+ return bytes
end
end