├── Makefile ├── README ├── config ├── doc └── us │ ├── examples.html │ ├── index.html │ ├── license.html │ ├── luazip-128.png │ └── manual.html ├── makefile.win ├── src ├── luazip.c ├── luazip.def └── luazip.h ├── tests ├── a │ └── b │ │ └── c.zip ├── a2 │ ├── b2.ext2 │ └── b2.zip ├── a3.ext3 ├── a3.zip ├── luazip.zip └── test_zip.lua ├── vc6 ├── README ├── luazip.dsw ├── luazip.rc ├── luazip_dll.dsp ├── luazip_static.dsp └── resource.h └── vc7 ├── README ├── luazip.rc ├── luazip.sln ├── luazip_dll.vcproj ├── luazip_static.vcproj └── resource.h /Makefile: -------------------------------------------------------------------------------- 1 | # $Id: Makefile,v 1.10 2006-07-24 01:24:36 tomas Exp $ 2 | 3 | T= zip 4 | V= 1.2.3 5 | CONFIG= ./config 6 | 7 | include $(CONFIG) 8 | 9 | ifeq "$(LUA_VERSION_NUM)" "500" 10 | COMPAT_O= $(COMPAT_DIR)/compat-5.1.o 11 | endif 12 | 13 | SRCS= src/lua$T.c 14 | OBJS= src/lua$T.o $(COMPAT_O) 15 | 16 | 17 | lib: src/$(LIBNAME) 18 | 19 | src/$(LIBNAME): $(OBJS) 20 | export MACOSX_DEPLOYMENT_TARGET="10.3"; $(CC) $(CFLAGS) $(LIB_OPTION) -o src/$(LIBNAME) $(OBJS) -lzzip 21 | 22 | $(COMPAT_DIR)/compat-5.1.o: $(COMPAT_DIR)/compat-5.1.c 23 | $(CC) -c $(CFLAGS) -o $@ $(COMPAT_DIR)/compat-5.1.c 24 | 25 | install: src/$(LIBNAME) 26 | mkdir -p $(LUA_LIBDIR) 27 | cp src/$(LIBNAME) $(LUA_LIBDIR) 28 | cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so 29 | 30 | clean: 31 | rm -f $L src/$(LIBNAME) $(OBJS) 32 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | LuaZip 1.2.3 2 | ------------ 3 | 4 | LuaZip is a lightweight Lua extension library used to read files stored inside zip files. 5 | The API is very similar to the standard Lua I/O library API.

6 | 7 | LuaZip is free software and uses the same license as Lua 5.1. 8 | Please see docs at doc/index.html or http://www.keplerproject.org/luazip 9 | -------------------------------------------------------------------------------- /config: -------------------------------------------------------------------------------- 1 | # Installation directories 2 | 3 | # Default prefix 4 | PREFIX = /usr/local 5 | 6 | # System's libraries directory (where binary libraries are installed) 7 | LUA_LIBDIR= $(PREFIX)/lib/lua/5.1 8 | 9 | # System's lua directory (where Lua libraries are installed) 10 | LUA_DIR= $(PREFIX)/share/lua/5.1 11 | 12 | # Lua includes directory 13 | LUA_INC= $(PREFIX)/include 14 | 15 | # Zziplib includes directory 16 | ZZLIB_INC= /usr/local/include 17 | 18 | # OS dependent 19 | LIB_OPTION= -shared #for Linux 20 | #LIB_OPTION= -bundle -undefined dynamic_lookup #for MacOS X 21 | 22 | # Lua version number (first and second digits of target version) 23 | LUA_VERSION_NUM= 500 24 | LIBNAME= $T.so.$V 25 | COMPAT_DIR= ../compat/src 26 | 27 | # Compilation directives 28 | WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings 29 | INCS= -I$(LUA_INC) -I$(ZZLIB_INC) -I$(COMPAT_DIR) 30 | CFLAGS= $(WARN) $(INCS) 31 | CC= gcc 32 | 33 | # $Id: config,v 1.7 2007-10-29 22:59:10 carregal Exp $ 34 | -------------------------------------------------------------------------------- /doc/us/examples.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | LuaZip: Reading files inside zip files 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 17 |
LuaZip
18 |
Reading files inside zip files
19 |
20 | 21 |
22 | 23 | 53 | 54 |
55 | 56 | 57 |

Example

58 | 59 |

60 | Suppose we have the following file hierarchy: 61 |

62 | 63 |
 64 | /a
 65 |     /b
 66 |         c.zip
 67 | /a2
 68 |     b2.ext2
 69 | /a3.ext3
 70 | /luazip.zip
 71 | 
72 | 73 |
    74 |
  • c.zip contains the file 'd.txt'
  • 75 |
  • b2.ext2 is a zip file containing the file 'c2/d2.txt'
  • 76 |
  • a3.ext3 is a zip file containing the file 'b3/c3/d3.txt'
  • 77 |
  • luazip.zip contains the files 'luazip.h', 'luazip.c', 'Makefile', 'README'
  • 78 |
79 | 80 | Below is a small sample code displaying the basic use of the library. 81 | 82 |
 83 | require "zip"
 84 | 
 85 | local zfile, err = zip.open('luazip.zip')
 86 | 
 87 | -- print the filenames of the files inside the zip
 88 | for file in zfile:files() do
 89 | 	print(file.filename)
 90 | end
 91 | 
 92 | -- open README and print it
 93 | local f1, err = zfile:open('README')
 94 | local s1 = f1:read("*a")
 95 | print(s1)
 96 | 
 97 | f1:close()
 98 | zfile:close()
 99 | 
100 | -- open d.txt inside c.zip
101 | local d, err = zip.openfile('a/b/c/d.txt')
102 | assert(d, err)
103 | d:close()
104 | 
105 | -- open d2.txt inside b2.ext2
106 | local d2, err = zip.openfile('a2/b2/c2/d2.txt', "ext2")
107 | assert(d2, err)
108 | d2:close()
109 | 
110 | -- open d3.txt inside a3.ext3
111 | local d3, err = zip.openfile('a3/b3/c3/d3.txt', {"ext2", "ext3"})
112 | assert(d3, err)
113 | d3:close()
114 | 
115 | 116 |
117 | 118 |
119 | 120 |
121 |

Valid XHTML 1.0!

122 |

$Id: examples.html,v 1.5 2007-06-18 18:47:05 carregal Exp $

123 |
124 | 125 |
126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /doc/us/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | LuaZip: Reading files inside zip files 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 17 |
LuaZip
18 |
Reading files inside zip files
19 |
20 | 21 |
22 | 23 | 54 | 55 |
56 | 57 |

Overview

58 | 59 |

LuaZip is a lightweight Lua extension library 60 | used to read files stored inside zip files. The API is very similar to the standard 61 | Lua I/O library API.

62 | 63 |

LuaZip is free software and uses the same license as Lua 5.1.

64 | 65 |

Status

66 | 67 |

Current version is 1.2.3. It was developed for Lua 5.0 and 5.1.

68 | 69 |

Download

70 | 71 |

LuaZip source can be downloaded from its 72 | Lua Forge 73 | page. If you are using LuaBinaries 74 | a Windows binary version of LuaZip can be found at the same LuaForge page.

75 | 76 |

History

77 | 78 |
79 |
Version 1.2.3 [18/Jun/2007]
80 |
Adapted to work on both Lua 5.0 and Lua 5.1.
81 | 82 |
Version 1.2.2 [24/Mar/2006]
83 |
Minor fixes on makefile and config
84 | 85 |
Version 1.2.1 [08/Jun/2005]
86 |
Minor bug fixes
87 | 88 |
Version 1.2.0 [01/Dec/2004]
89 |
90 | 91 |
Version 1.1.3 [25/Jun/2004]
92 |
First Public Release
93 |
94 | 95 |

Credits

96 | 97 |

LuaZip was designed and coded by Danilo Tuler as part of the 98 | Kepler Project.

99 | 100 |

Contact

101 | 102 |

For more information please 103 | contact us. 104 | Comments are welcome!

105 | 106 |

You can also reach other Kepler developers and users on the Kepler Project 107 | mailing list.

108 | 109 |
110 | 111 |
112 | 113 |
114 |

115 | Valid XHTML 1.0!

116 |

$Id: index.html,v 1.10 2007-06-18 18:47:05 carregal Exp $

117 |
118 | 119 |
120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /doc/us/license.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | LuaZip: Reading files inside zip files 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 17 |
LuaZip
18 |
Reading files inside zip files
19 |
20 | 21 |
22 | 23 | 53 | 54 |
55 | 56 |

License

57 | 58 |

59 | LuaZip is free software: it can be used for both academic and commercial purposes at absolutely no cost. 60 | There are no royalties or GNU-like "copyleft" restrictions. 61 | LuaZip qualifies as Open Source 62 | software. 63 | Its licenses are compatible with GPL. 64 | LuaZip is not in the public domain and the Kepler Project 65 | keep its copyright. The legal details are below. 66 |

67 | 68 |

69 | The spirit of the license is that 70 | you are free to use LuaZip for any purpose at no cost without having to ask us. 71 | The only requirement is that 72 | if you do use LuaZip, 73 | then you should give us credit by including the appropriate copyright notice 74 | somewhere in your product or its documentation. 75 |

76 | 77 |

78 | The LuaZip library was designed and implemented by Danilo Tuler. 79 | Part of the code is a derived work from the Lua standard I/O library, copyrighted by Tecgraf, PUC-Rio. 80 |

81 | 82 |
83 |

84 | Copyright © 2003-2007 The Kepler Project. 85 |

86 | 87 |

88 | Permission is hereby granted, free of charge, to any person obtaining a copy 89 | of this software and associated documentation files (the "Software"), to deal 90 | in the Software without restriction, including without limitation the rights 91 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 92 | copies of the Software, and to permit persons to whom the Software is 93 | furnished to do so, subject to the following conditions: 94 |

95 | 96 |

97 | The above copyright notice and this permission notice shall be included in 98 | all copies or substantial portions of the Software. 99 |

100 | 101 |

102 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 103 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 104 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 105 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 106 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 107 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 108 | THE SOFTWARE. 109 |

110 | 111 |
112 | 113 |
114 | 115 |
116 |

Valid XHTML 1.0!

117 |

$Id: license.html,v 1.6 2007-06-18 18:47:05 carregal Exp $

118 |
119 | 120 |
121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /doc/us/luazip-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/doc/us/luazip-128.png -------------------------------------------------------------------------------- /doc/us/manual.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | LuaZip: Reading files inside zip files 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 17 |
LuaZip
18 |
Reading files inside zip files
19 |
20 | 21 |
22 | 23 | 54 | 55 |
56 | 57 | 58 |

Introduction

59 | 60 |

LuaZip is a lightweight Lua extension library 61 | that can be used to read files stored inside zip files. It uses 62 | zziplib to do all the hard work.

63 | 64 |

The API exposed to Lua is very simple and very similiar to the usual file handling 65 | functions provided by the 66 | I/O Lua standard library. 67 | In fact, the API is so similar that parts of this manual are extracted from the Lua manual, 68 | copyrighted by Tecgraf, PUC-Rio.

69 | 70 |

Building

71 | 72 |

73 | LuaZip could be built to Lua 5.0 or to Lua 5.1. 74 | In both cases, the language library and headers files for the target version 75 | must be installed properly. 76 |

77 | 78 |

79 | LuaZip offers a Makefile and a separate configuration file, 80 | config, which should be edited to suit your installation 81 | before runnig make. 82 | The file has some definitions like paths to the external libraries, 83 | compiler options and the like. 84 | One important definition is the version of Lua language, 85 | which is not obtained from the installed software. 86 |

87 | 88 |

LuaZip compilation depends on 89 | zziplib 0.13.49 and 90 | zlib 1.2.3. 91 |

92 | 93 |

Installation

94 | 95 |

The LuaZip compiled binary should be copied to a directory in your 96 | C path. 97 | Lua 5.0 users should also install Compat-5.1.

98 | 99 | 100 |

Reference

101 | 102 |
103 |
zip.open (filename)
104 |
This function opens a zip file and returns a new zip file handle. In case of 105 | error it returns nil and an error message. Unlike io.open, there is no 106 | mode parameter, as the only supported mode is "read".
107 | 108 |
zip.openfile (filename [, extensions]])
109 |
This function opens a file and returns a file handle. In case of 110 | error it returns nil and an error message. Unlike io.open, there is no 111 | mode parameter, as the only supported mode is "read".
112 | This function implements a virtual file system based on optionally compressed files. 113 | Instead of simply looking for a file at a given path, this function goes recursively up 114 | through all path separators ("/") looking for zip files there. If it finds a zip file, 115 | this function use the remaining path to open the requested file.
116 | The optional parameter extensions allows the use of file extensions other than .zip 117 | during the lookup. It can be a string corresponding to the extension or an indexed table 118 | with the lookup extensions sequence.
119 | 120 |
zfile:close ()
121 |
This function closes a zfile opened by zip.open
122 | 123 |
zfile:files ()
124 |
Returns an iterator function that returns a new table containing the 125 | following information each time it is called: 126 |
    127 |
  • filename: the full path of a file
  • 128 |
  • compressed_size: the compressed size of the file in bytes
  • 129 |
  • uncompressed_size: the uncompressed size of the file in bytes
  • 130 |
131 |
132 | 133 |
zfile:open (filename)
134 |
This function opens a file that is stored inside the zip file opened by zip.open.
135 | The filename may contain the full path of the file contained inside the zip. The 136 | directory separator must be '/'.
137 | Unlike f:open, there is no mode parameter, as the only 138 | supported mode is "read".
139 | 140 |
file:read (format1, ...)
141 |
Reads a file according to the given formats, which specify what to read.
142 | For each format, the function returns a string with the characters read, or nil if it cannot read 143 | data with the specified format. When called without formats, it uses a default format that reads 144 | the entire next line (see below).
145 | The available formats are: 146 |
    147 |
  • "*a": reads the whole file, starting at the current position. On end of file, it 148 | returns the empty string.
  • 149 |
  • "*l": reads the next line (skipping the end of line), returns nil on end of file. 150 | This is the default format.
  • 151 |
  • number: reads a string with up to that number of characters, returning nil 152 | on end of file.
  • 153 |
154 |
155 | Unlike the standard I/O read, the format "*n" is not supported.
156 | 157 |
file:seek ([whence] [, offset])
158 |
Sets and gets the file position, measured from the beginning of the file, to the position given 159 | by offset plus a base specified by the string whence, as follows: 160 |
    161 |
  • set: base is position 0 (beginning of the file);
  • 162 |
  • cur: base is current position;
  • 163 |
  • end: base is end of file;
  • 164 |
165 | In case of success, function seek returns the final file position, measured in bytes 166 | from the beginning of the file. If this function fails, it returns nil, plus an error string. 167 | The default value for whence is "cur", and for offset is 0. 168 | Therefore, the call file:seek() returns the current file position, without changing 169 | it; the call file:seek("set") sets the position to the beginning of the file (and returns 0); 170 | and the call file:seek("end") sets the position to the end of the file, and returns its 171 | size.
172 | 173 |
file:close ()
174 |
This function closes a file opened by zfile:open.
175 | 176 |
file:lines ()
177 |
Returns an iterator function that returns a new line from the file each time it is called. 178 | Therefore, the construction
179 |
for line in file:lines() do ... end
180 | will iterate over all lines of the file.
181 |
182 | 183 |
184 | 185 |
186 | 187 |
188 |

Valid XHTML 1.0!

189 |

$Id: manual.html,v 1.12 2007-06-18 18:47:05 carregal Exp $

190 |
191 | 192 |
193 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /makefile.win: -------------------------------------------------------------------------------- 1 | LUA_INC=c:\lua5.1\include 2 | LUA_DIR=c:\lua5.1\lua 3 | LUA_LIBDIR=c:\lua5.1 4 | LUA_LIB=c:\lua5.1\lua5.1.lib 5 | 6 | OBJS= src\luazip.obj 7 | 8 | ZZLIB_INCLUDE=c:\zziplib-0.13.49 9 | ZZLIB_LIB=c:\zziplib-0.13.49\zzip\zziplib.lib 10 | 11 | ZLIB_INCLUDE=c:\zziplib-0.13.49\zlib\include 12 | ZLIB_LIB=c:\zziplib-0.13.49\zlib\lib\zlib.lib 13 | 14 | .c.obj: 15 | cl /c /Fo$@ /O2 /I$(LUA_INC) /I$(ZZLIB_INCLUDE) /I$(ZLIB_INCLUDE) /D_CRT_SECURE_NO_DEPRECATE $< 16 | 17 | src\zip.dll: $(OBJS) 18 | link /dll /def:src\luazip.def /out:$@ $(OBJS) $(ZZLIB_LIB) $(ZLIB_LIB) $(LUA_LIB) 19 | 20 | install: src\zip.dll 21 | IF NOT EXIST $(LUA_LIBDIR) mkdir $(LUA_LIBDIR) 22 | copy src\zip.dll $(LUA_LIBDIR) 23 | 24 | clean: 25 | del src\zip.dll 26 | del src\*.obj 27 | del src\zip.exp 28 | del src\zip.lib 29 | 30 | # $Id: makefile.win,v 1.2 2007-06-13 23:41:54 carregal Exp $ 31 | -------------------------------------------------------------------------------- /src/luazip.c: -------------------------------------------------------------------------------- 1 | /* 2 | LuaZip - Reading files inside zip files. 3 | http://www.keplerproject.org/luazip/ 4 | 5 | Author: Danilo Tuler 6 | Copyright (c) 2003-2007 Kepler Project 7 | 8 | $Id: luazip.c,v 1.11 2007-06-18 18:47:05 carregal Exp $ 9 | */ 10 | 11 | #include 12 | #include 13 | #include "zzip/zzip.h" 14 | #include "luazip.h" 15 | #include "lauxlib.h" 16 | #if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 17 | #include "compat-5.1.h" 18 | #endif 19 | 20 | #define ZIPFILEHANDLE "lzipFile" 21 | #define ZIPINTERNALFILEHANDLE "lzipInternalFile" 22 | #define LUAZIP_MAX_EXTENSIONS 32 23 | 24 | static int pushresult (lua_State *L, int i, const char *filename) { 25 | if (i) { 26 | lua_pushboolean(L, 1); 27 | return 1; 28 | } 29 | else { 30 | lua_pushnil(L); 31 | if (filename) 32 | lua_pushfstring(L, "%s: %s", filename, zzip_strerror(zzip_errno(errno))); 33 | else 34 | lua_pushfstring(L, "%s", zzip_strerror(zzip_errno(errno))); 35 | lua_pushnumber(L, zzip_errno(errno)); 36 | return 3; 37 | } 38 | } 39 | 40 | static ZZIP_DIR** topfile (lua_State *L, int findex) { 41 | ZZIP_DIR** f = (ZZIP_DIR**)luaL_checkudata(L, findex, ZIPFILEHANDLE); 42 | if (f == NULL) luaL_argerror(L, findex, "bad zip file"); 43 | return f; 44 | } 45 | 46 | static ZZIP_DIR* tofile (lua_State *L, int findex) { 47 | ZZIP_DIR** f = topfile(L, findex); 48 | if (*f == NULL) 49 | luaL_error(L, "attempt to use a closed zip file"); 50 | return *f; 51 | } 52 | 53 | static ZZIP_FILE** topinternalfile (lua_State *L, int findex) { 54 | ZZIP_FILE** f = (ZZIP_FILE**)luaL_checkudata(L, findex, ZIPINTERNALFILEHANDLE); 55 | if (f == NULL) luaL_argerror(L, findex, "bad zip file"); 56 | return f; 57 | } 58 | 59 | static ZZIP_FILE* tointernalfile (lua_State *L, int findex) { 60 | ZZIP_FILE** f = topinternalfile(L, findex); 61 | if (*f == NULL) 62 | luaL_error(L, "attempt to use a closed zip file"); 63 | return *f; 64 | } 65 | 66 | /* 67 | ** When creating file handles, always creates a `closed' file handle 68 | ** before opening the actual file; so, if there is a memory error, the 69 | ** file is not left opened. 70 | */ 71 | static ZZIP_DIR** newfile (lua_State *L) { 72 | ZZIP_DIR** pf = (ZZIP_DIR**)lua_newuserdata(L, sizeof(ZZIP_DIR*)); 73 | *pf = NULL; /* file handle is currently `closed' */ 74 | luaL_getmetatable(L, ZIPFILEHANDLE); 75 | lua_setmetatable(L, -2); 76 | return pf; 77 | } 78 | 79 | static ZZIP_FILE** newinternalfile (lua_State *L) { 80 | ZZIP_FILE** pf = (ZZIP_FILE**)lua_newuserdata(L, sizeof(ZZIP_FILE*)); 81 | *pf = NULL; /* file handle is currently `closed' */ 82 | luaL_getmetatable(L, ZIPINTERNALFILEHANDLE); 83 | lua_setmetatable(L, -2); 84 | return pf; 85 | } 86 | 87 | 88 | static int zip_open (lua_State *L) { 89 | const char *zipfilename = luaL_checkstring(L, 1); 90 | /*const char *mode = luaL_optstring(L, 2, "r");*/ 91 | 92 | ZZIP_DIR** pf = newfile(L); 93 | *pf = zzip_dir_open(zipfilename, 0); 94 | if (*pf == NULL) 95 | { 96 | lua_pushnil(L); 97 | lua_pushfstring(L, "could not open file `%s'", zipfilename); 98 | return 2; 99 | } 100 | return 1; 101 | } 102 | 103 | static int zip_close (lua_State *L) { 104 | ZZIP_DIR* f = tofile(L, 1); 105 | if (zzip_dir_close(f) == 0) 106 | { 107 | *(ZZIP_DIR**)lua_touserdata(L, 1) = NULL; /* mark file as close */ 108 | lua_pushboolean(L, 1); 109 | } 110 | else 111 | lua_pushboolean(L, 0); 112 | return 1; 113 | } 114 | 115 | static int f_open (lua_State *L) { 116 | ZZIP_DIR* uf = tofile(L, 1); 117 | const char *filename = luaL_checkstring(L, 2); 118 | /*const char *mode = luaL_optstring(L, 3, "r");*/ 119 | ZZIP_FILE** inf = newinternalfile(L); 120 | 121 | *inf = zzip_file_open(uf, filename, 0); 122 | if (*inf) 123 | return 1; 124 | 125 | lua_pushnil(L); 126 | lua_pushfstring(L, "could not open file `%s'", filename); 127 | return 2; 128 | } 129 | 130 | /* 131 | 132 | */ 133 | static int zip_openfile (lua_State *L) { 134 | ZZIP_FILE** inf; 135 | 136 | const char * ext2[LUAZIP_MAX_EXTENSIONS+1]; 137 | zzip_strings_t *ext = ext2; 138 | 139 | const char *filename = luaL_checkstring(L, 1); 140 | /*const char *mode = luaL_optstring(L, 2, "r");*/ 141 | 142 | inf = newinternalfile(L); 143 | 144 | if (lua_isstring(L, 2)) 145 | { 146 | /* creates a table with the string as the first and only (numerical) element */ 147 | lua_newtable(L); 148 | lua_pushvalue(L, 2); 149 | lua_rawseti(L, -2, 1); 150 | 151 | /* replaces the string by the table with the string inside */ 152 | lua_replace(L, 2); 153 | } 154 | 155 | if (lua_istable(L, 2)) 156 | { 157 | int i, m, n; 158 | 159 | /* how many extension were specified? */ 160 | n = luaL_getn(L, 2); 161 | 162 | if (n > LUAZIP_MAX_EXTENSIONS) 163 | { 164 | luaL_error(L, "too many extensions specified"); 165 | } 166 | 167 | for (i = 0, m = 0; i < n; i++) 168 | { 169 | lua_rawgeti(L, 2, i+1); 170 | if (lua_isstring(L, -1)) 171 | { 172 | /* luazip specifies "zip" as the extension, but zziplib expects ".zip" */ 173 | lua_pushstring(L, "."); 174 | lua_insert(L, -2); 175 | lua_concat(L, 2); 176 | 177 | ext2[m] = lua_tostring(L, -1); 178 | m++; 179 | } 180 | lua_pop(L, 1); 181 | } 182 | ext2[m] = 0; 183 | 184 | *inf = zzip_open_ext_io(filename, 0, 0664, ext, 0); 185 | } 186 | else 187 | { 188 | *inf = zzip_open(filename, 0); 189 | } 190 | 191 | if (*inf) 192 | return 1; 193 | 194 | lua_pushnil(L); 195 | lua_pushfstring(L, "could not open file `%s'", filename); 196 | return 2; 197 | } 198 | 199 | static int zip_type (lua_State *L) { 200 | ZZIP_DIR** f = (ZZIP_DIR**)luaL_checkudata(L, 1, ZIPFILEHANDLE); 201 | if (f == NULL) lua_pushnil(L); 202 | else if (*f == NULL) 203 | lua_pushliteral(L, "closed zip file"); 204 | else 205 | lua_pushliteral(L, "zip file"); 206 | return 1; 207 | } 208 | 209 | static int zip_tostring (lua_State *L) { 210 | char buff[32]; 211 | ZZIP_DIR** f = topfile(L, 1); 212 | if (*f == NULL) 213 | strcpy(buff, "closed"); 214 | else 215 | sprintf(buff, "%p", lua_touserdata(L, 1)); 216 | lua_pushfstring(L, "zip file (%s)", buff); 217 | return 1; 218 | } 219 | 220 | static int ff_tostring (lua_State *L) { 221 | char buff[32]; 222 | ZZIP_FILE** f = topinternalfile(L, 1); 223 | if (*f == NULL) 224 | strcpy(buff, "closed"); 225 | else 226 | sprintf(buff, "%p", lua_touserdata(L, 1)); 227 | lua_pushfstring(L, "file in zip file (%s)", buff); 228 | return 1; 229 | } 230 | 231 | static int zip_gc (lua_State *L) { 232 | ZZIP_DIR**f = topfile(L, 1); 233 | if (*f != NULL) /* ignore closed files */ 234 | zip_close(L); 235 | return 0; 236 | } 237 | 238 | static int zip_readfile (lua_State *L) { 239 | ZZIP_DIRENT* ent = NULL; 240 | ZZIP_DIR* uf = NULL; 241 | 242 | uf = *(ZZIP_DIR**)lua_touserdata(L, lua_upvalueindex(1)); 243 | if (uf == NULL) /* file is already closed? */ 244 | luaL_error(L, "file is already closed"); 245 | 246 | ent = zzip_readdir(uf); 247 | 248 | if (ent == NULL) 249 | return 0; 250 | 251 | lua_newtable(L); 252 | lua_pushstring(L, "compressed_size"); lua_pushnumber(L, ent->d_csize); lua_settable(L, -3); 253 | lua_pushstring(L, "compression_method"); lua_pushnumber(L, ent->d_compr); lua_settable(L, -3); 254 | lua_pushstring(L, "uncompressed_size"); lua_pushnumber(L, ent->st_size); lua_settable(L, -3); 255 | lua_pushstring(L, "filename"); lua_pushstring(L, ent->d_name); lua_settable(L, -3); 256 | 257 | return 1; 258 | } 259 | 260 | static int f_files (lua_State *L) { 261 | ZZIP_DIR *f = tofile(L, 1); 262 | zzip_rewinddir(f); 263 | lua_pushliteral(L, ZIPFILEHANDLE); 264 | lua_rawget(L, LUA_REGISTRYINDEX); 265 | lua_pushcclosure(L, zip_readfile, 2); 266 | return 1; 267 | } 268 | 269 | static int aux_close (lua_State *L) { 270 | ZZIP_FILE *f = tointernalfile(L, 1); 271 | int ok = (zzip_fclose(f) == 0); 272 | if (ok) 273 | *(ZZIP_FILE **)lua_touserdata(L, 1) = NULL; /* mark file as closed */ 274 | return ok; 275 | } 276 | 277 | static int ff_close (lua_State *L) { 278 | return pushresult(L, aux_close(L), NULL); 279 | } 280 | 281 | static int ff_gc (lua_State *L) { 282 | ZZIP_FILE**f = topinternalfile(L, 1); 283 | if (*f != NULL) /* ignore closed files */ 284 | aux_close(L); 285 | return 0; 286 | } 287 | 288 | static int zzip_getc (ZZIP_FILE *f) 289 | { 290 | char c; 291 | return (zzip_fread(&c, sizeof(char), 1, f) == 0) ? EOF : (int)c; 292 | } 293 | 294 | static char* zzip_fgets(char *str, int size, ZZIP_FILE *stream) 295 | { 296 | int c, i; 297 | 298 | for (i = 0; i < size-1; i++) 299 | { 300 | c = zzip_getc(stream); 301 | if (EOF == c) 302 | return NULL; 303 | str[i]=c; 304 | if (('\n' == c)/* || ('\r' == c)*/) 305 | { 306 | str[i++]='\n'; 307 | break; 308 | } 309 | } 310 | str[i] = '\0'; 311 | 312 | return str; 313 | } 314 | 315 | /* no support to read numbers 316 | static int zzip_fscanf (ZZIP_FILE *f, const char *format, ...) 317 | { 318 | // TODO 319 | return 0; 320 | } 321 | 322 | static int read_number (lua_State *L, ZZIP_FILE *f) { 323 | lua_Number d; 324 | if (zzip_fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { 325 | lua_pushnumber(L, d); 326 | return 1; 327 | } 328 | else return 0; // read fails 329 | } 330 | */ 331 | 332 | static int test_eof (lua_State *L, ZZIP_FILE *f) { 333 | /* TODO */ 334 | (void) L; 335 | (void) f; 336 | return 1; 337 | } 338 | 339 | static int read_line (lua_State *L, ZZIP_FILE *f) { 340 | luaL_Buffer b; 341 | luaL_buffinit(L, &b); 342 | for (;;) { 343 | size_t l; 344 | char *p = luaL_prepbuffer(&b); 345 | if (zzip_fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ 346 | luaL_pushresult(&b); /* close buffer */ 347 | return (lua_strlen(L, -1) > 0); /* check whether read something */ 348 | } 349 | l = strlen(p); 350 | if (p[l-1] != '\n') 351 | luaL_addsize(&b, l); 352 | else { 353 | luaL_addsize(&b, l - 1); /* do not include `eol' */ 354 | luaL_pushresult(&b); /* close buffer */ 355 | return 1; /* read at least an `eol' */ 356 | } 357 | } 358 | } 359 | 360 | static int read_chars (lua_State *L, ZZIP_FILE *f, size_t n) { 361 | size_t rlen; /* how much to read */ 362 | size_t nr; /* number of chars actually read */ 363 | luaL_Buffer b; 364 | luaL_buffinit(L, &b); 365 | rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ 366 | do { 367 | char *p = luaL_prepbuffer(&b); 368 | if (rlen > n) rlen = n; /* cannot read more than asked */ 369 | nr = zzip_fread(p, sizeof(char), rlen, f); 370 | luaL_addsize(&b, nr); 371 | n -= nr; /* still have to read `n' chars */ 372 | } while (n > 0 && nr == rlen); /* until end of count or eof */ 373 | luaL_pushresult(&b); /* close buffer */ 374 | return (n == 0 || lua_strlen(L, -1) > 0); 375 | } 376 | 377 | static int g_read (lua_State *L, ZZIP_FILE *f, int first) { 378 | int nargs = lua_gettop(L) - 1; 379 | int success; 380 | int n; 381 | if (nargs == 0) { /* no arguments? */ 382 | success = read_line(L, f); 383 | n = first+1; /* to return 1 result */ 384 | } 385 | else { /* ensure stack space for all results and for auxlib's buffer */ 386 | luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); 387 | success = 1; 388 | for (n = first; nargs-- && success; n++) { 389 | if (lua_type(L, n) == LUA_TNUMBER) { 390 | size_t l = (size_t)lua_tonumber(L, n); 391 | success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); 392 | } 393 | else { 394 | const char *p = lua_tostring(L, n); 395 | luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); 396 | switch (p[1]) { 397 | case 'l': /* line */ 398 | success = read_line(L, f); 399 | break; 400 | case 'a': /* file */ 401 | read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ 402 | success = 1; /* always success */ 403 | break; 404 | default: 405 | return luaL_argerror(L, n, "invalid format"); 406 | } 407 | } 408 | } 409 | } 410 | if (!success) { 411 | lua_pop(L, 1); /* remove last result */ 412 | lua_pushnil(L); /* push nil instead */ 413 | } 414 | return n - first; 415 | } 416 | 417 | static int ff_read (lua_State *L) { 418 | return g_read(L, tointernalfile(L, 1), 2); 419 | } 420 | 421 | static int zip_readline (lua_State *L); 422 | 423 | static void aux_lines (lua_State *L, int idx, int close) { 424 | lua_pushliteral(L, ZIPINTERNALFILEHANDLE); 425 | lua_rawget(L, LUA_REGISTRYINDEX); 426 | lua_pushvalue(L, idx); 427 | lua_pushboolean(L, close); /* close/not close file when finished */ 428 | lua_pushcclosure(L, zip_readline, 3); 429 | } 430 | 431 | static int ff_lines (lua_State *L) { 432 | tointernalfile(L, 1); /* check that it's a valid file handle */ 433 | aux_lines(L, 1, 0); 434 | return 1; 435 | } 436 | 437 | static int zip_readline (lua_State *L) { 438 | ZZIP_FILE *f = *(ZZIP_FILE **)lua_touserdata(L, lua_upvalueindex(2)); 439 | if (f == NULL) /* file is already closed? */ 440 | luaL_error(L, "file is already closed"); 441 | if (read_line(L, f)) return 1; 442 | else { /* EOF */ 443 | if (lua_toboolean(L, lua_upvalueindex(3))) { /* generator created file? */ 444 | lua_settop(L, 0); 445 | lua_pushvalue(L, lua_upvalueindex(2)); 446 | aux_close(L); /* close it */ 447 | } 448 | return 0; 449 | } 450 | } 451 | 452 | static int ff_seek (lua_State *L) { 453 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; 454 | static const char *const modenames[] = {"set", "cur", "end", NULL}; 455 | ZZIP_FILE *f = tointernalfile(L, 1); 456 | long offset = luaL_optlong(L, 3, 0); 457 | #if ! defined (LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 458 | int op = luaL_findstring(luaL_optstring(L, 2, "cur"), modenames); 459 | luaL_argcheck(L, op != -1, 2, "invalid mode"); 460 | #else 461 | int op = luaL_checkoption(L, 2, "cur", modenames); 462 | #endif 463 | op = zzip_seek(f, offset, mode[op]); 464 | if (op < 0) 465 | return pushresult(L, 0, NULL); /* error */ 466 | else { 467 | lua_pushnumber(L, zzip_tell(f)); 468 | return 1; 469 | } 470 | } 471 | 472 | static const luaL_reg ziplib[] = { 473 | {"open", zip_open}, 474 | {"close", zip_close}, 475 | {"type", zip_type}, 476 | // {"files", io_files}, 477 | {"openfile", zip_openfile}, 478 | {NULL, NULL} 479 | }; 480 | 481 | static const luaL_reg flib[] = { 482 | {"open", f_open}, 483 | {"close", zip_close}, 484 | {"files", f_files}, 485 | {"__gc", zip_gc}, 486 | {"__tostring", zip_tostring}, 487 | {NULL, NULL} 488 | }; 489 | 490 | static const luaL_reg fflib[] = { 491 | {"read", ff_read}, 492 | {"close", ff_close}, 493 | {"seek", ff_seek}, 494 | {"lines", ff_lines}, 495 | {"__gc", ff_gc}, 496 | {"__tostring", ff_tostring}, 497 | /* {"flush", ff_flush}, 498 | {"write", ff_write},*/ 499 | {NULL, NULL} 500 | }; 501 | 502 | 503 | /* 504 | ** Assumes the table is on top of the stack. 505 | */ 506 | static void set_info (lua_State *L) { 507 | lua_pushliteral (L, "_COPYRIGHT"); 508 | lua_pushliteral (L, "Copyright (C) 2003-2007 Kepler Project"); 509 | lua_settable (L, -3); 510 | lua_pushliteral (L, "_DESCRIPTION"); 511 | lua_pushliteral (L, "Reading files inside zip files"); 512 | lua_settable (L, -3); 513 | lua_pushliteral (L, "_VERSION"); 514 | lua_pushliteral (L, "LuaZip 1.2.3"); 515 | lua_settable (L, -3); 516 | } 517 | 518 | static void createmeta (lua_State *L) { 519 | luaL_newmetatable(L, ZIPFILEHANDLE); /* create new metatable for file handles */ 520 | /* file methods */ 521 | lua_pushliteral(L, "__index"); 522 | lua_pushvalue(L, -2); /* push metatable */ 523 | lua_rawset(L, -3); /* metatable.__index = metatable */ 524 | luaL_openlib(L, NULL, flib, 0); 525 | 526 | luaL_newmetatable(L, ZIPINTERNALFILEHANDLE); /* create new metatable for internal file handles */ 527 | /* internal file methods */ 528 | lua_pushliteral(L, "__index"); 529 | lua_pushvalue(L, -2); /* push metatable */ 530 | lua_rawset(L, -3); /* metatable.__index = metatable */ 531 | luaL_openlib(L, NULL, fflib, 0); 532 | } 533 | 534 | LUAZIP_API int luaopen_zip (lua_State *L) { 535 | createmeta(L); 536 | lua_pushvalue(L, -1); 537 | luaL_openlib(L, LUA_ZIPLIBNAME, ziplib, 1); 538 | set_info(L); 539 | return 1; 540 | } 541 | -------------------------------------------------------------------------------- /src/luazip.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | luaopen_zip -------------------------------------------------------------------------------- /src/luazip.h: -------------------------------------------------------------------------------- 1 | /* 2 | LuaZip - Reading files inside zip files. 3 | http://www.keplerproject.org/luazip/ 4 | 5 | Author: Danilo Tuler 6 | Copyright (c) 2003-2007 Kepler Project 7 | 8 | $Id: luazip.h,v 1.5 2007-06-18 18:47:05 carregal Exp $ 9 | */ 10 | 11 | #ifndef luazip_h 12 | #define luazip_h 13 | 14 | #include "lua.h" 15 | 16 | #ifndef LUAZIP_API 17 | #define LUAZIP_API LUA_API 18 | #endif 19 | 20 | #define LUA_ZIPLIBNAME "zip" 21 | LUAZIP_API int luaopen_zip (lua_State *L); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /tests/a/b/c.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/a/b/c.zip -------------------------------------------------------------------------------- /tests/a2/b2.ext2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/a2/b2.ext2 -------------------------------------------------------------------------------- /tests/a2/b2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/a2/b2.zip -------------------------------------------------------------------------------- /tests/a3.ext3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/a3.ext3 -------------------------------------------------------------------------------- /tests/a3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/a3.zip -------------------------------------------------------------------------------- /tests/luazip.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/tests/luazip.zip -------------------------------------------------------------------------------- /tests/test_zip.lua: -------------------------------------------------------------------------------- 1 | --[[------------------------------------------------------------------------ 2 | test_zip.lua 3 | test code for luazip 4 | --]]------------------------------------------------------------------------ 5 | 6 | -- compatibility code for Lua version 5.0 providing 5.1 behavior 7 | if string.find (_VERSION, "Lua 5.0") and not package then 8 | if not LUA_PATH then 9 | LUA_PATH = os.getenv("LUA_PATH") or "./?.lua;" 10 | end 11 | require"compat-5.1" 12 | package.cpath = os.getenv("LUA_CPATH") or "./?.so;./?.dll;./?.dylib" 13 | end 14 | 15 | require('zip') 16 | 17 | function test_open () 18 | local zfile, err = zip.open('luazip.zip') 19 | 20 | assert(zfile, err) 21 | 22 | print("File list begin") 23 | for file in zfile:files() do 24 | print(file.filename) 25 | end 26 | print("File list ended OK!") 27 | print() 28 | 29 | print("Testing zfile:open") 30 | local f1, err = zfile:open('README') 31 | assert(f1, err) 32 | 33 | local f2, err = zfile:open('luazip.h') 34 | assert(f2, err) 35 | print("zfile:open OK!") 36 | print() 37 | 38 | print("Testing reading by number") 39 | local c = f1:read(1) 40 | while c ~= nil do 41 | io.write(c) 42 | c = f1:read(1) 43 | end 44 | 45 | print() 46 | print("OK") 47 | print() 48 | end 49 | 50 | function test_openfile () 51 | print("Testing the openfile magic") 52 | 53 | local d, err = zip.openfile('a/b/c/d.txt') 54 | assert(d, err) 55 | 56 | local e, err = zip.openfile('a/b/c/e.txt') 57 | assert(e == nil, err) 58 | 59 | local d2, err = zip.openfile('a2/b2/c2/d2.txt', "ext2") 60 | assert(d2, err) 61 | 62 | local e2, err = zip.openfile('a2/b2/c2/e2.txt', "ext2") 63 | assert(e2 == nil, err) 64 | 65 | local d3, err = zip.openfile('a3/b3/c3/d3.txt', {"ext2", "ext3"}) 66 | assert(d3, err) 67 | 68 | local e3, err = zip.openfile('a3/b3/c3/e3.txt', {"ext2", "ext3"}) 69 | assert(e3 == nil, err) 70 | 71 | print("Smooth magic!") 72 | print() 73 | end 74 | 75 | test_open() 76 | test_openfile() 77 | -------------------------------------------------------------------------------- /vc6/README: -------------------------------------------------------------------------------- 1 | These are the Visual Studio 6 projects provided by the Kepler Project 2 | 3 | Files: 4 | 5 | luazip_dll.dsp 6 | luazip_static.dsp 7 | luazip.dsw 8 | README 9 | 10 | Generated files: 11 | 12 | luazip.ncb 13 | luazip.opt 14 | 15 | ../lib/vc6/libzip.lib 16 | ../lib/vc6/libzipd.lib 17 | ../lib/vc6/zip.exp 18 | ../lib/vc6/zip.lib 19 | ../lib/vc6/zipd.exp 20 | ../lib/vc6/zipd.lib 21 | ../lib/vc6/zipd.pdb 22 | 23 | ../bin/vc6/zip.dll 24 | ../bin/vc6/zipd.dll 25 | ../bin/vc6/zipd.ilk 26 | 27 | Download source from: 28 | http://prdownloads.sourceforge.net/zziplib/zziplib-0.12.83.tar.bz2?download -------------------------------------------------------------------------------- /vc6/luazip.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "luazip_dll"=.\luazip_dll.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /vc6/luazip.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/vc6/luazip.rc -------------------------------------------------------------------------------- /vc6/luazip_dll.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="luazip_dll" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 6 | 7 | CFG=luazip_dll - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "luazip_dll.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "luazip_dll.mak" CFG="luazip_dll - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "luazip_dll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") 21 | !MESSAGE "luazip_dll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | MTL=midl.exe 30 | RSC=rc.exe 31 | 32 | !IF "$(CFG)" == "luazip_dll - Win32 Release" 33 | 34 | # PROP BASE Use_MFC 0 35 | # PROP BASE Use_Debug_Libraries 0 36 | # PROP BASE Output_Dir "Release" 37 | # PROP BASE Intermediate_Dir "Release" 38 | # PROP BASE Target_Dir "" 39 | # PROP Use_MFC 0 40 | # PROP Use_Debug_Libraries 0 41 | # PROP Output_Dir "../lib/vc6" 42 | # PROP Intermediate_Dir "luazip_dll/Release" 43 | # PROP Ignore_Export_Lib 0 44 | # PROP Target_Dir "" 45 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAZIP_EXPORTS" /YX /FD /c 46 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "../../external-src/lua50/include" /I "../../external-src/zlib/include" /I "../../external-src/zziplib-0.12.83" /I "../../compat/src" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAZIP_EXPORTS" /D LUAZIP_API=__declspec(dllexport) /FR /YX /FD /c 47 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 48 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 49 | # ADD BASE RSC /l 0x416 /d "NDEBUG" 50 | # ADD RSC /l 0x416 /d "NDEBUG" 51 | BSC32=bscmake.exe 52 | # ADD BASE BSC32 /nologo 53 | # ADD BSC32 /nologo 54 | LINK32=link.exe 55 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 56 | # ADD LINK32 lua50.lib zdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../bin/vc6/zip.dll" /libpath:"../../external-src/lua50/lib/dll" /libpath:"../../external-src/zlib/lib" 57 | # Begin Special Build Tool 58 | SOURCE="$(InputPath)" 59 | PostBuild_Cmds=cd ../bin/vc6 zip.exe luazip-1.2.1-win32.zip zip.dll 60 | # End Special Build Tool 61 | 62 | !ELSEIF "$(CFG)" == "luazip_dll - Win32 Debug" 63 | 64 | # PROP BASE Use_MFC 0 65 | # PROP BASE Use_Debug_Libraries 1 66 | # PROP BASE Output_Dir "Debug" 67 | # PROP BASE Intermediate_Dir "Debug" 68 | # PROP BASE Target_Dir "" 69 | # PROP Use_MFC 0 70 | # PROP Use_Debug_Libraries 1 71 | # PROP Output_Dir "../lib/vc6" 72 | # PROP Intermediate_Dir "luazip_dll/Debug" 73 | # PROP Ignore_Export_Lib 0 74 | # PROP Target_Dir "" 75 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAZIP_EXPORTS" /YX /FD /GZ /c 76 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../external-src/lua50/include" /I "../../external-src/zlib/include" /I "../../external-src/zziplib-0.12.83" /I "../../compat/src" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LUAZIP_EXPORTS" /D LUAZIP_API=__declspec(dllexport) /FR /YX /FD /GZ /c 77 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 78 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 79 | # ADD BASE RSC /l 0x416 /d "_DEBUG" 80 | # ADD RSC /l 0x416 /d "_DEBUG" 81 | BSC32=bscmake.exe 82 | # ADD BASE BSC32 /nologo 83 | # ADD BSC32 /nologo 84 | LINK32=link.exe 85 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept 86 | # ADD LINK32 lua50.lib zdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../bin/vc6/zipd.dll" /pdbtype:sept /libpath:"../../external-src/lua50/lib/dll" /libpath:"../../external-src/zlib/lib" 87 | 88 | !ENDIF 89 | 90 | # Begin Target 91 | 92 | # Name "luazip_dll - Win32 Release" 93 | # Name "luazip_dll - Win32 Debug" 94 | # Begin Group "Source Files" 95 | 96 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 97 | # Begin Source File 98 | 99 | SOURCE="..\..\compat\src\compat-5.1.c" 100 | # End Source File 101 | # Begin Source File 102 | 103 | SOURCE=..\src\luazip.c 104 | # End Source File 105 | # Begin Source File 106 | 107 | SOURCE=.\luazip.rc 108 | # End Source File 109 | # End Group 110 | # Begin Group "Header Files" 111 | 112 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 113 | # Begin Source File 114 | 115 | SOURCE="..\..\compat\src\compat-5.1.h" 116 | # End Source File 117 | # Begin Source File 118 | 119 | SOURCE=..\src\luazip.h 120 | # End Source File 121 | # End Group 122 | # Begin Group "Resource Files" 123 | 124 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 125 | # End Group 126 | # Begin Group "zziplib Files" 127 | 128 | # PROP Default_Filter "" 129 | # Begin Source File 130 | 131 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\dir.c" 132 | # End Source File 133 | # Begin Source File 134 | 135 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\err.c" 136 | # End Source File 137 | # Begin Source File 138 | 139 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\file.c" 140 | # End Source File 141 | # Begin Source File 142 | 143 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\info.c" 144 | # End Source File 145 | # Begin Source File 146 | 147 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\plugin.c" 148 | # End Source File 149 | # Begin Source File 150 | 151 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\stat.c" 152 | # End Source File 153 | # Begin Source File 154 | 155 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\write.c" 156 | # End Source File 157 | # Begin Source File 158 | 159 | SOURCE="..\..\external-src\zziplib-0.12.83\zzip\zip.c" 160 | # End Source File 161 | # End Group 162 | # End Target 163 | # End Project 164 | -------------------------------------------------------------------------------- /vc6/luazip_static.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="luazip_static" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=luazip_static - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "luazip_static.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "luazip_static.mak" CFG="luazip_static - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "luazip_static - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "luazip_static - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "luazip_static - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "../lib/vc6" 41 | # PROP Intermediate_Dir "luazip_static/Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "../../lua/include" /I "../../zlib/include" /I "../zziplib-0.12.83" /I "../../compat" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x416 /d "NDEBUG" 46 | # ADD RSC /l 0x416 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo /out:"../lib/vc6/libzip.lib" 53 | 54 | !ELSEIF "$(CFG)" == "luazip_static - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "../lib/vc6" 64 | # PROP Intermediate_Dir "luazip_static/Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../../lua/include" /I "../../zlib/include" /I "../zziplib-0.12.83" /I "../../compat" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x416 /d "_DEBUG" 69 | # ADD RSC /l 0x416 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo /out:"../lib/vc6/libzipd.lib" 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "luazip_static - Win32 Release" 82 | # Name "luazip_static - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE="..\..\compat\compat-5.1.c" 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=..\luazip.c 93 | # End Source File 94 | # End Group 95 | # Begin Group "Header Files" 96 | 97 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 98 | # Begin Source File 99 | 100 | SOURCE="..\..\compat\compat-5.1.h" 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=..\luazip.h 105 | # End Source File 106 | # End Group 107 | # Begin Group "zziplib Files" 108 | 109 | # PROP Default_Filter "" 110 | # Begin Source File 111 | 112 | SOURCE="..\zziplib-0.12.83\zzip\dir.c" 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE="..\zziplib-0.12.83\zzip\err.c" 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE="..\zziplib-0.12.83\zzip\file.c" 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE="..\zziplib-0.12.83\zzip\info.c" 125 | # End Source File 126 | # Begin Source File 127 | 128 | SOURCE="..\zziplib-0.12.83\zzip\plugin.c" 129 | # End Source File 130 | # Begin Source File 131 | 132 | SOURCE="..\zziplib-0.12.83\zzip\stat.c" 133 | # End Source File 134 | # Begin Source File 135 | 136 | SOURCE="..\zziplib-0.12.83\zzip\write.c" 137 | # End Source File 138 | # Begin Source File 139 | 140 | SOURCE="..\zziplib-0.12.83\zzip\zip.c" 141 | # End Source File 142 | # End Group 143 | # End Target 144 | # End Project 145 | -------------------------------------------------------------------------------- /vc6/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by luazip.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1000 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /vc7/README: -------------------------------------------------------------------------------- 1 | These are the Visual Studio 7 projects provided by the Kepler Project 2 | 3 | Files: 4 | 5 | luazip_dll.vcproj 6 | luazip_static.vcproj 7 | luazip.sln 8 | README 9 | 10 | Generated files: 11 | 12 | lzip.suo 13 | 14 | ../lib/vc7/libzip.lib 15 | ../lib/vc7/libzipd.lib 16 | ../lib/vc7/zip.exp 17 | ../lib/vc7/zip.lib 18 | ../lib/vc7/zipd.exp 19 | ../lib/vc7/zipd.lib 20 | ../lib/vc7/zipd.pdb 21 | 22 | ../bin/vc7/zip.dll 23 | ../bin/vc7/zipd.dll 24 | ../bin/vc7/zipd.ilk 25 | 26 | Download source from: 27 | http://prdownloads.sourceforge.net/zziplib/zziplib-0.12.83.tar.bz2?download -------------------------------------------------------------------------------- /vc7/luazip.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luaforge/luazip/0b8f5c958e170b1b49f05bc267bc0351ad4dfc44/vc7/luazip.rc -------------------------------------------------------------------------------- /vc7/luazip.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luazip_dll", "luazip_dll.vcproj", "{F7323180-F4E8-4994-9DE4-DB985CF23033}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luazip_static", "luazip_static.vcproj", "{F4571BC6-4181-4D7C-BA2A-4398140445D0}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfiguration) = preSolution 12 | Debug = Debug 13 | Release = Release 14 | EndGlobalSection 15 | GlobalSection(ProjectConfiguration) = postSolution 16 | {F7323180-F4E8-4994-9DE4-DB985CF23033}.Debug.ActiveCfg = Debug|Win32 17 | {F7323180-F4E8-4994-9DE4-DB985CF23033}.Debug.Build.0 = Debug|Win32 18 | {F7323180-F4E8-4994-9DE4-DB985CF23033}.Release.ActiveCfg = Release|Win32 19 | {F7323180-F4E8-4994-9DE4-DB985CF23033}.Release.Build.0 = Release|Win32 20 | {F4571BC6-4181-4D7C-BA2A-4398140445D0}.Debug.ActiveCfg = Debug|Win32 21 | {F4571BC6-4181-4D7C-BA2A-4398140445D0}.Debug.Build.0 = Debug|Win32 22 | {F4571BC6-4181-4D7C-BA2A-4398140445D0}.Release.ActiveCfg = Release|Win32 23 | {F4571BC6-4181-4D7C-BA2A-4398140445D0}.Release.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(ExtensibilityGlobals) = postSolution 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityAddIns) = postSolution 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /vc7/luazip_dll.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 12 | 13 | 14 | 22 | 39 | 41 | 51 | 59 | 61 | 63 | 65 | 69 | 71 | 73 | 75 | 77 | 79 | 80 | 88 | 105 | 107 | 118 | 126 | 128 | 130 | 132 | 136 | 138 | 140 | 142 | 144 | 146 | 147 | 148 | 149 | 150 | 151 | 154 | 156 | 157 | 159 | 161 | 166 | 167 | 169 | 176 | 177 | 178 | 180 | 181 | 182 | 185 | 187 | 188 | 190 | 191 | 193 | 194 | 195 | 198 | 200 | 202 | 207 | 208 | 210 | 217 | 218 | 219 | 221 | 223 | 228 | 229 | 231 | 238 | 239 | 240 | 242 | 244 | 249 | 250 | 252 | 259 | 260 | 261 | 263 | 265 | 270 | 271 | 273 | 280 | 281 | 282 | 284 | 286 | 291 | 292 | 294 | 301 | 302 | 303 | 305 | 307 | 312 | 313 | 315 | 322 | 323 | 324 | 326 | 328 | 333 | 334 | 336 | 343 | 344 | 345 | 347 | 349 | 354 | 355 | 357 | 364 | 365 | 366 | 367 | 370 | 371 | 372 | 373 | 374 | 375 | -------------------------------------------------------------------------------- /vc7/luazip_static.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 21 | 38 | 40 | 44 | 46 | 48 | 50 | 52 | 56 | 58 | 60 | 62 | 64 | 65 | 73 | 89 | 91 | 95 | 97 | 99 | 101 | 103 | 107 | 109 | 111 | 113 | 115 | 116 | 117 | 118 | 119 | 120 | 123 | 125 | 126 | 128 | 130 | 135 | 136 | 138 | 144 | 145 | 146 | 147 | 150 | 152 | 153 | 155 | 156 | 157 | 160 | 162 | 164 | 169 | 170 | 172 | 178 | 179 | 180 | 182 | 184 | 189 | 190 | 192 | 198 | 199 | 200 | 202 | 204 | 209 | 210 | 212 | 218 | 219 | 220 | 222 | 224 | 229 | 230 | 232 | 238 | 239 | 240 | 242 | 244 | 249 | 250 | 252 | 258 | 259 | 260 | 262 | 264 | 269 | 270 | 272 | 278 | 279 | 280 | 282 | 284 | 289 | 290 | 292 | 298 | 299 | 300 | 302 | 304 | 309 | 310 | 312 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | -------------------------------------------------------------------------------- /vc7/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by luazip.rc 4 | // 5 | #define IDS_PROJNAME 100 6 | #define IDR_WMDMLOGGER 101 7 | #define IDS_LOG_SEV_INFO 201 8 | #define IDS_LOG_SEV_WARN 202 9 | #define IDS_LOG_SEV_ERROR 203 10 | #define IDS_LOG_DATETIME 204 11 | #define IDS_LOG_SRCNAME 205 12 | #define IDS_DEF_LOGFILE 301 13 | #define IDS_DEF_MAXSIZE 302 14 | #define IDS_DEF_SHRINKTOSIZE 303 15 | #define IDS_DEF_LOGENABLED 304 16 | #define IDS_MUTEX_TIMEOUT 401 17 | 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | #define _APS_NEXT_RESOURCE_VALUE 201 23 | #define _APS_NEXT_COMMAND_VALUE 32768 24 | #define _APS_NEXT_CONTROL_VALUE 201 25 | #define _APS_NEXT_SYMED_VALUE 101 26 | #endif 27 | #endif 28 | --------------------------------------------------------------------------------