zipruby 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of zipruby might be problematic. Click here for more details.

Files changed (60) hide show
  1. data/README.txt +131 -0
  2. data/ext/extconf.rb +1 -1
  3. data/ext/libzip.mswin32.patch +113 -0
  4. data/ext/libzip.vcproj +308 -0
  5. data/ext/libzip.vcproj.IBM-94B792EFFD1.sugawara.user +37 -0
  6. data/ext/mkstemp.c +143 -0
  7. data/ext/zip.h +211 -0
  8. data/ext/zip_add.c +52 -0
  9. data/ext/zip_add_dir.c +83 -0
  10. data/ext/zip_close.c +566 -0
  11. data/ext/zip_delete.c +61 -0
  12. data/ext/zip_dirent.c +531 -0
  13. data/ext/zip_entry_free.c +55 -0
  14. data/ext/zip_entry_new.c +81 -0
  15. data/ext/zip_err_str.c +72 -0
  16. data/ext/zip_error.c +104 -0
  17. data/ext/zip_error_clear.c +47 -0
  18. data/ext/zip_error_get.c +47 -0
  19. data/ext/zip_error_get_sys_type.c +50 -0
  20. data/ext/zip_error_strerror.c +93 -0
  21. data/ext/zip_error_to_str.c +77 -0
  22. data/ext/zip_fclose.c +74 -0
  23. data/ext/zip_file_error_clear.c +47 -0
  24. data/ext/zip_file_error_get.c +47 -0
  25. data/ext/zip_file_get_offset.c +77 -0
  26. data/ext/zip_file_strerror.c +47 -0
  27. data/ext/zip_fopen.c +52 -0
  28. data/ext/zip_fopen_index.c +219 -0
  29. data/ext/zip_fread.c +125 -0
  30. data/ext/zip_free.c +83 -0
  31. data/ext/zip_get_archive_comment.c +63 -0
  32. data/ext/zip_get_file_comment.c +61 -0
  33. data/ext/zip_get_name.c +74 -0
  34. data/ext/zip_get_num_files.c +50 -0
  35. data/ext/zip_memdup.c +58 -0
  36. data/ext/zip_name_locate.c +95 -0
  37. data/ext/zip_new.c +71 -0
  38. data/ext/zip_open.c +520 -0
  39. data/ext/zip_rename.c +52 -0
  40. data/ext/zip_replace.c +81 -0
  41. data/ext/zip_set_archive_comment.c +68 -0
  42. data/ext/zip_set_file_comment.c +69 -0
  43. data/ext/zip_set_name.c +77 -0
  44. data/ext/zip_source_buffer.c +160 -0
  45. data/ext/zip_source_file.c +71 -0
  46. data/ext/zip_source_filep.c +176 -0
  47. data/ext/zip_source_free.c +54 -0
  48. data/ext/zip_source_function.c +62 -0
  49. data/ext/zip_source_zip.c +189 -0
  50. data/ext/zip_stat.c +52 -0
  51. data/ext/zip_stat_index.c +93 -0
  52. data/ext/zip_stat_init.c +53 -0
  53. data/ext/zip_strerror.c +47 -0
  54. data/ext/zip_unchange.c +84 -0
  55. data/ext/zip_unchange_all.c +56 -0
  56. data/ext/zip_unchange_archive.c +52 -0
  57. data/ext/zip_unchange_data.c +53 -0
  58. data/ext/zipint.h +240 -0
  59. data/ext/zipruby.h +1 -1
  60. metadata +63 -5
data/README.txt ADDED
@@ -0,0 +1,131 @@
1
+ = Zip/Ruby
2
+
3
+ Copyright (c) 2008 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
4
+
5
+ == Description
6
+
7
+ Ruby bindings for libzip.
8
+
9
+ libzip is a C library for reading, creating, and modifying zip archives.
10
+
11
+ == Project Page
12
+
13
+ http://rubyforge.org/projects/zipruby
14
+
15
+ == Install
16
+
17
+ gem install zipruby
18
+
19
+ == Download
20
+
21
+ https://rubyforge.org/frs/?group_id=6124
22
+
23
+ == Example
24
+ === reading zip archives
25
+
26
+ require 'zipruby'
27
+
28
+ Zip::Archive.open('filename.zip') do |ar|
29
+ n = ar.num_files # number of entries
30
+
31
+ n.times do |i|
32
+ entry_name = ar.get_name(i) # get entry name from archive
33
+
34
+ # open entry
35
+ ar.fopen(entry_name) do |f| # or ar.fopen(i) do |f|
36
+ name = f.name # name of the file
37
+ size = f.size # size of file (uncompressed)
38
+ comp_size = f.comp_size # size of file (compressed)
39
+
40
+ content = f.read # read entry content
41
+ end
42
+ end
43
+
44
+ # Zip::Archive includes Enumerable
45
+ entry_names = ar.map do |f|
46
+ f.naem
47
+ end
48
+ end
49
+
50
+ === creating zip archives
51
+
52
+ require 'zipruby'
53
+
54
+ Zip::Archive.open('filename.zip', Zip::CREATE) do |ar|
55
+ ar.add_file('foo.txt') # add file to zip archive
56
+
57
+ # add file to zip archive from File object
58
+ open('bar.txt') do |f|
59
+ ar << f # or ar.add_filep(f)
60
+ end
61
+
62
+ # add file to zip archive from buffer
63
+ ar.add_buffer('zoo.txt', 'Hello, world!')
64
+ end
65
+
66
+ === modifying zip archives
67
+
68
+ require 'zipruby'
69
+
70
+ Zip::Archive.open('filename.zip') do |ar|
71
+ # replace file in zip archive
72
+ ar.replace_file(0, 'foo.txt')
73
+
74
+ # replace file in zip archive with File object
75
+ open('bar.txt') do |f|
76
+ ar.replace_filep(1, f)
77
+ end
78
+
79
+ # replace file in zip archive with buffer
80
+ ar.replace_buffer(2, 'Hello, world!')
81
+
82
+ # add or replace file in zip archive
83
+ ar.add_or_replace_file(3, 'foo.txt')
84
+ end
85
+
86
+ # ar1 imports ar2 entries
87
+ Zip::Archive.open('ar1.zip') do |ar1|
88
+ Zip::Archive.open('ar2.zip') do |ar2|
89
+ ar1.update(ar2)
90
+ end
91
+ end
92
+
93
+ == License
94
+ Copyright (c) 2008 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
95
+ All rights reserved.
96
+
97
+ Redistribution and use in source and binary forms, with or without modification,
98
+ are permitted provided that the following conditions are met:
99
+
100
+ * Redistributions of source code must retain the above copyright notice,
101
+ this list of conditions and the following disclaimer.
102
+ * Redistributions in binary form must reproduce the above copyright notice,
103
+ this list of conditions and the following disclaimer in the documentation
104
+ and/or other materials provided with the distribution.
105
+ * The names of its contributors may be used to endorse or promote products
106
+ derived from this software without specific prior written permission.
107
+
108
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
109
+ ANY EXPRESS OR IMPLIED WARRANTIES,
110
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
111
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
112
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
113
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
114
+ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
115
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
116
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
117
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
118
+ DAMAGE.
119
+
120
+ === libzip
121
+ Zip/Ruby contains libzip.
122
+
123
+ libzip is a C library for reading, creating, and modifying zip archives.
124
+
125
+ * distribution site:
126
+ * http://www.nih.at/libzip/
127
+ * ftp.nih.at /pub/nih/libzip
128
+
129
+ * authors:
130
+ * Dieter Baron <dillo@giga.or.at>
131
+ * Thomas Klausner <tk@giga.or.at>
data/ext/extconf.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'mkmf'
2
2
 
3
- if have_header('zip.h') and have_library('zip') and have_library('z')
3
+ if have_header('zlib.h') and have_library('z')
4
4
  create_makefile('zipruby')
5
5
  end
@@ -0,0 +1,113 @@
1
+ diff -ru libzip-0.8.orig/lib/mkstemp.c libzip-0.8/lib/mkstemp.c
2
+ --- libzip-0.8.orig/lib/mkstemp.c 2007-05-16 10:41:34.000000000 +0900
3
+ +++ libzip-0.8/lib/mkstemp.c 2008-04-22 23:14:12.140625000 +0900
4
+ @@ -43,6 +43,15 @@
5
+ #include <stdio.h>
6
+ #include <stdlib.h>
7
+
8
+ +#ifdef _WIN32
9
+ +#include <io.h>
10
+ +#include <process.h>
11
+ +#define getpid() _getpid()
12
+ +typedef int pid_t;
13
+ +#define S_ISDIR(m) (((m) & (_S_IFMT)) == (_S_IFDIR))
14
+ +#define open(p, f, m) _open((p), ((f) | _O_BINARY), _S_IREAD | _S_IWRITE)
15
+ +#endif
16
+ +
17
+ int
18
+ _zip_mkstemp(char *path)
19
+ {
20
+ diff -ru libzip-0.8.orig/lib/zip.h libzip-0.8/lib/zip.h
21
+ --- libzip-0.8.orig/lib/zip.h 2007-06-05 00:21:20.000000000 +0900
22
+ +++ libzip-0.8/lib/zip.h 2008-04-22 23:14:12.140625000 +0900
23
+ @@ -46,6 +46,10 @@
24
+ #include <stdio.h>
25
+ #include <time.h>
26
+
27
+ +#ifdef _WIN32
28
+ +typedef int ssize_t;
29
+ +#endif
30
+ +
31
+ /* flags for zip_open */
32
+
33
+ #define ZIP_CREATE 1
34
+ diff -ru libzip-0.8.orig/lib/zip_close.c libzip-0.8/lib/zip_close.c
35
+ --- libzip-0.8.orig/lib/zip_close.c 2007-06-05 00:21:20.000000000 +0900
36
+ +++ libzip-0.8/lib/zip_close.c 2008-04-22 23:15:48.203125000 +0900
37
+ @@ -42,6 +42,13 @@
38
+ #include <sys/types.h>
39
+ #include <sys/stat.h>
40
+
41
+ +#ifdef _WIN32
42
+ +#include <windows.h>
43
+ +#include <io.h>
44
+ +#define close(f) _close(f)
45
+ +#define rename(s, d) (MoveFileExA((s), (d), MOVEFILE_REPLACE_EXISTING) ? 0 : -1)
46
+ +#endif
47
+ +
48
+ #include "zip.h"
49
+ #include "zipint.h"
50
+
51
+ @@ -65,7 +72,9 @@
52
+ int i, j, error;
53
+ char *temp;
54
+ FILE *out;
55
+ +#ifndef _WIN32
56
+ mode_t mask;
57
+ +#endif
58
+ struct zip_cdir *cd;
59
+ struct zip_dirent de;
60
+ int reopen_on_error;
61
+ @@ -242,9 +251,11 @@
62
+ }
63
+ return -1;
64
+ }
65
+ +#ifndef _WIN32
66
+ mask = umask(0);
67
+ umask(mask);
68
+ chmod(za->zn, 0666&~mask);
69
+ +#endif
70
+
71
+ _zip_free(za);
72
+ free(temp);
73
+ diff -ru libzip-0.8.orig/lib/zip_error_to_str.c libzip-0.8/lib/zip_error_to_str.c
74
+ --- libzip-0.8.orig/lib/zip_error_to_str.c 2007-05-16 10:41:34.000000000 +0900
75
+ +++ libzip-0.8/lib/zip_error_to_str.c 2008-04-22 23:14:12.140625000 +0900
76
+ @@ -40,6 +40,10 @@
77
+ #include <stdlib.h>
78
+ #include <string.h>
79
+
80
+ +#ifdef _WIN32
81
+ +#define snprintf _snprintf
82
+ +#endif
83
+ +
84
+ #include "zip.h"
85
+ #include "zipint.h"
86
+
87
+ diff -ru libzip-0.8.orig/lib/zip_name_locate.c libzip-0.8/lib/zip_name_locate.c
88
+ --- libzip-0.8.orig/lib/zip_name_locate.c 2007-06-05 00:21:21.000000000 +0900
89
+ +++ libzip-0.8/lib/zip_name_locate.c 2008-04-22 23:14:12.156250000 +0900
90
+ @@ -37,6 +37,10 @@
91
+
92
+ #include <string.h>
93
+
94
+ +#ifdef _WIN32
95
+ +#define strcasecmp _stricmp
96
+ +#endif
97
+ +
98
+ #include "zip.h"
99
+ #include "zipint.h"
100
+
101
+ diff -ru libzip-0.8.orig/lib/zipint.h libzip-0.8/lib/zipint.h
102
+ --- libzip-0.8.orig/lib/zipint.h 2007-06-05 00:21:21.000000000 +0900
103
+ +++ libzip-0.8/lib/zipint.h 2008-04-22 23:14:12.156250000 +0900
104
+ @@ -39,7 +39,9 @@
105
+ #include <zlib.h>
106
+
107
+ #include "zip.h"
108
+ +#ifndef _WIN32
109
+ #include "config.h"
110
+ +#endif
111
+
112
+ #ifndef HAVE_MKSTEMP
113
+ int _zip_mkstemp(char *);
data/ext/libzip.vcproj ADDED
@@ -0,0 +1,308 @@
1
+ <?xml version="1.0" encoding="shift_jis"?>
2
+ <VisualStudioProject
3
+ ProjectType="Visual C++"
4
+ Version="9.00"
5
+ Name="libzip"
6
+ ProjectGUID="{E34589B5-6623-49AE-AF73-8881E3C81946}"
7
+ RootNamespace="libzip"
8
+ Keyword="Win32Proj"
9
+ TargetFrameworkVersion="196613"
10
+ >
11
+ <Platforms>
12
+ <Platform
13
+ Name="Win32"
14
+ />
15
+ </Platforms>
16
+ <ToolFiles>
17
+ </ToolFiles>
18
+ <Configurations>
19
+ <Configuration
20
+ Name="Release|Win32"
21
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
22
+ IntermediateDirectory="$(ConfigurationName)"
23
+ ConfigurationType="4"
24
+ CharacterSet="1"
25
+ WholeProgramOptimization="1"
26
+ >
27
+ <Tool
28
+ Name="VCPreBuildEventTool"
29
+ />
30
+ <Tool
31
+ Name="VCCustomBuildTool"
32
+ />
33
+ <Tool
34
+ Name="VCXMLDataGeneratorTool"
35
+ />
36
+ <Tool
37
+ Name="VCWebServiceProxyGeneratorTool"
38
+ />
39
+ <Tool
40
+ Name="VCMIDLTool"
41
+ />
42
+ <Tool
43
+ Name="VCCLCompilerTool"
44
+ Optimization="2"
45
+ EnableIntrinsicFunctions="true"
46
+ AdditionalIncludeDirectories="&quot;C:\usr\local\zlib123-dll\include&quot;"
47
+ PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS"
48
+ RuntimeLibrary="0"
49
+ EnableFunctionLevelLinking="true"
50
+ UsePrecompiledHeader="0"
51
+ WarningLevel="3"
52
+ DebugInformationFormat="3"
53
+ DisableSpecificWarnings="4018;4996"
54
+ />
55
+ <Tool
56
+ Name="VCManagedResourceCompilerTool"
57
+ />
58
+ <Tool
59
+ Name="VCResourceCompilerTool"
60
+ />
61
+ <Tool
62
+ Name="VCPreLinkEventTool"
63
+ />
64
+ <Tool
65
+ Name="VCLibrarianTool"
66
+ AdditionalDependencies="zdll.lib"
67
+ AdditionalLibraryDirectories="&quot;C:\usr\local\zlib123-dll\lib&quot;"
68
+ />
69
+ <Tool
70
+ Name="VCALinkTool"
71
+ />
72
+ <Tool
73
+ Name="VCXDCMakeTool"
74
+ />
75
+ <Tool
76
+ Name="VCBscMakeTool"
77
+ />
78
+ <Tool
79
+ Name="VCFxCopTool"
80
+ />
81
+ <Tool
82
+ Name="VCPostBuildEventTool"
83
+ />
84
+ </Configuration>
85
+ </Configurations>
86
+ <References>
87
+ </References>
88
+ <Files>
89
+ <File
90
+ RelativePath=".\libzip.mswin32.patch"
91
+ >
92
+ </File>
93
+ <File
94
+ RelativePath=".\mkstemp.c"
95
+ >
96
+ </File>
97
+ <File
98
+ RelativePath=".\zip.h"
99
+ >
100
+ </File>
101
+ <File
102
+ RelativePath=".\zip_add.c"
103
+ >
104
+ </File>
105
+ <File
106
+ RelativePath=".\zip_add_dir.c"
107
+ >
108
+ </File>
109
+ <File
110
+ RelativePath=".\zip_close.c"
111
+ >
112
+ </File>
113
+ <File
114
+ RelativePath=".\zip_delete.c"
115
+ >
116
+ </File>
117
+ <File
118
+ RelativePath=".\zip_dirent.c"
119
+ >
120
+ </File>
121
+ <File
122
+ RelativePath=".\zip_entry_free.c"
123
+ >
124
+ </File>
125
+ <File
126
+ RelativePath=".\zip_entry_new.c"
127
+ >
128
+ </File>
129
+ <File
130
+ RelativePath=".\zip_err_str.c"
131
+ >
132
+ </File>
133
+ <File
134
+ RelativePath=".\zip_error.c"
135
+ >
136
+ </File>
137
+ <File
138
+ RelativePath=".\zip_error_clear.c"
139
+ >
140
+ </File>
141
+ <File
142
+ RelativePath=".\zip_error_get.c"
143
+ >
144
+ </File>
145
+ <File
146
+ RelativePath=".\zip_error_get_sys_type.c"
147
+ >
148
+ </File>
149
+ <File
150
+ RelativePath=".\zip_error_strerror.c"
151
+ >
152
+ </File>
153
+ <File
154
+ RelativePath=".\zip_error_to_str.c"
155
+ >
156
+ </File>
157
+ <File
158
+ RelativePath=".\zip_fclose.c"
159
+ >
160
+ </File>
161
+ <File
162
+ RelativePath=".\zip_file_error_clear.c"
163
+ >
164
+ </File>
165
+ <File
166
+ RelativePath=".\zip_file_error_get.c"
167
+ >
168
+ </File>
169
+ <File
170
+ RelativePath=".\zip_file_get_offset.c"
171
+ >
172
+ </File>
173
+ <File
174
+ RelativePath=".\zip_file_strerror.c"
175
+ >
176
+ </File>
177
+ <File
178
+ RelativePath=".\zip_fopen.c"
179
+ >
180
+ </File>
181
+ <File
182
+ RelativePath=".\zip_fopen_index.c"
183
+ >
184
+ </File>
185
+ <File
186
+ RelativePath=".\zip_fread.c"
187
+ >
188
+ </File>
189
+ <File
190
+ RelativePath=".\zip_free.c"
191
+ >
192
+ </File>
193
+ <File
194
+ RelativePath=".\zip_get_archive_comment.c"
195
+ >
196
+ </File>
197
+ <File
198
+ RelativePath=".\zip_get_file_comment.c"
199
+ >
200
+ </File>
201
+ <File
202
+ RelativePath=".\zip_get_name.c"
203
+ >
204
+ </File>
205
+ <File
206
+ RelativePath=".\zip_get_num_files.c"
207
+ >
208
+ </File>
209
+ <File
210
+ RelativePath=".\zip_memdup.c"
211
+ >
212
+ </File>
213
+ <File
214
+ RelativePath=".\zip_name_locate.c"
215
+ >
216
+ </File>
217
+ <File
218
+ RelativePath=".\zip_new.c"
219
+ >
220
+ </File>
221
+ <File
222
+ RelativePath=".\zip_open.c"
223
+ >
224
+ </File>
225
+ <File
226
+ RelativePath=".\zip_rename.c"
227
+ >
228
+ </File>
229
+ <File
230
+ RelativePath=".\zip_replace.c"
231
+ >
232
+ </File>
233
+ <File
234
+ RelativePath=".\zip_set_archive_comment.c"
235
+ >
236
+ </File>
237
+ <File
238
+ RelativePath=".\zip_set_file_comment.c"
239
+ >
240
+ </File>
241
+ <File
242
+ RelativePath=".\zip_set_name.c"
243
+ >
244
+ </File>
245
+ <File
246
+ RelativePath=".\zip_source_buffer.c"
247
+ >
248
+ </File>
249
+ <File
250
+ RelativePath=".\zip_source_file.c"
251
+ >
252
+ </File>
253
+ <File
254
+ RelativePath=".\zip_source_filep.c"
255
+ >
256
+ </File>
257
+ <File
258
+ RelativePath=".\zip_source_free.c"
259
+ >
260
+ </File>
261
+ <File
262
+ RelativePath=".\zip_source_function.c"
263
+ >
264
+ </File>
265
+ <File
266
+ RelativePath=".\zip_source_zip.c"
267
+ >
268
+ </File>
269
+ <File
270
+ RelativePath=".\zip_stat.c"
271
+ >
272
+ </File>
273
+ <File
274
+ RelativePath=".\zip_stat_index.c"
275
+ >
276
+ </File>
277
+ <File
278
+ RelativePath=".\zip_stat_init.c"
279
+ >
280
+ </File>
281
+ <File
282
+ RelativePath=".\zip_strerror.c"
283
+ >
284
+ </File>
285
+ <File
286
+ RelativePath=".\zip_unchange.c"
287
+ >
288
+ </File>
289
+ <File
290
+ RelativePath=".\zip_unchange_all.c"
291
+ >
292
+ </File>
293
+ <File
294
+ RelativePath=".\zip_unchange_archive.c"
295
+ >
296
+ </File>
297
+ <File
298
+ RelativePath=".\zip_unchange_data.c"
299
+ >
300
+ </File>
301
+ <File
302
+ RelativePath=".\zipint.h"
303
+ >
304
+ </File>
305
+ </Files>
306
+ <Globals>
307
+ </Globals>
308
+ </VisualStudioProject>
@@ -0,0 +1,37 @@
1
+ <?xml version="1.0" encoding="shift_jis"?>
2
+ <VisualStudioUserFile
3
+ ProjectType="Visual C++"
4
+ Version="9.00"
5
+ ShowAllFiles="false"
6
+ >
7
+ <Configurations>
8
+ <Configuration
9
+ Name="Release|Win32"
10
+ >
11
+ <DebugSettings
12
+ Command=""
13
+ WorkingDirectory=""
14
+ CommandArguments=""
15
+ Attach="false"
16
+ DebuggerType="3"
17
+ Remote="1"
18
+ RemoteMachine="IBM-94B792EFFD1"
19
+ RemoteCommand=""
20
+ HttpUrl=""
21
+ PDBPath=""
22
+ SQLDebugging=""
23
+ Environment=""
24
+ EnvironmentMerge="true"
25
+ DebuggerFlavor=""
26
+ MPIRunCommand=""
27
+ MPIRunArguments=""
28
+ MPIRunWorkingDirectory=""
29
+ ApplicationCommand=""
30
+ ApplicationArguments=""
31
+ ShimCommand=""
32
+ MPIAcceptMode=""
33
+ MPIAcceptFilter=""
34
+ />
35
+ </Configuration>
36
+ </Configurations>
37
+ </VisualStudioUserFile>