lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


http://code.google.com/p/lua-archive/

The Lua Archive library can read and write compressed files in a variety of formats. Modules are provided for direct compression and decompression (zlib, bzip2), reading simply compressed files (gz, bz2), and for working with multi-file archives (tar, zip). Other formats, such as lzma, will be added soon.

Using zlib:
    decompressed = larc.zlib.decompress(compressed)
    z = larc.zlib.compressor{level=9}
    file:write(z(string.rep('a',100)))
    file:write(z(string.rep('b',100)))
    file:write(z()) -- flushes the output

Reading a bz2 file:
    bz2 = larc.bzfile.open("test.bz2")
    print(bz2:read("*line"))

Reading a zip file:
    zip = larc.zipfile.open("test.zip")
    for file in zip:names() do
      if string.match(file, "%.txt$") then
        zip:extract(file)
      end
    end

Lua Archive has a BSD-like license.

--
- tom
telliamed@whoopdedo.org