-- --- T2-COPYRIGHT-NOTE-BEGIN ---
-- This copyright note is auto-generated by ./scripts/Create-CopyPatch.
-- 
-- T2 SDE: misc/lua/lzlib/zlibtest.lua
-- Copyright (C) 2005 - 2006 The T2 SDE Project
-- 
-- More information can be found in the files COPYING and README.
-- 
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; version 2 of the License. A copy of the
-- GNU General Public License can be found in the file COPYING.
-- --- T2-COPYRIGHT-NOTE-END ---

-- output all lines of compressed file ./test.gz

require "lzlib"

zf,error = lzlib.open("./test.gz", "r");
if not zf then             -- failed to open file, print error
   print(error);
else
   lines = zf:lines();     -- obtain line iterator

   for x in lines do       -- output contents 
      print (x);
   end

   _,normal_eof,error = zf:eof ();
   if not normal_eof then  -- check if stream ended because of error
      print ("-- abnormal end of stream: ", error);
   end

   ok,error = zf:close();
   if not ok then
      print ("could not close stream: ", error);
   end

end
