1 --[[------------------------------------------------------------------------
4 --]]------------------------------------------------------------------------
6 -- compatibility code for Lua version 5.0 providing 5.1 behavior
7 if string.find (_VERSION
, "Lua 5.0") and not package
then
9 LUA_PATH
= os
.getenv("LUA_PATH") or "./?.lua;"
12 package
.cpath
= os
.getenv("LUA_CPATH") or "./?.so;./?.dll;./?.dylib"
18 local zfile
, err
= zip
.open('luazip.zip')
22 print("File list begin")
23 for file
in zfile
:files() do
26 print("File list ended OK!")
29 print("Testing zfile:open")
30 local f1
, err
= zfile
:open('README')
33 local f2
, err
= zfile
:open('luazip.h')
35 print("zfile:open OK!")
38 print("Testing reading by number")
50 function test_openfile ()
51 print("Testing the openfile magic")
53 local d
, err
= zip
.openfile('a/b/c/d.txt')
56 local e
, err
= zip
.openfile('a/b/c/e.txt')
59 local d2
, err
= zip
.openfile('a2/b2/c2/d2.txt', "ext2")
62 local e2
, err
= zip
.openfile('a2/b2/c2/e2.txt', "ext2")
63 assert(e2
== nil, err
)
65 local d3
, err
= zip
.openfile('a3/b3/c3/d3.txt', {"ext2", "ext3"})
68 local e3
, err
= zip
.openfile('a3/b3/c3/e3.txt', {"ext2", "ext3"})
69 assert(e3
== nil, err
)
71 print("Smooth magic!")