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
@@ -0,0 +1,61 @@
1
+ /*
2
+ $NiH: zip_get_file_comment.c,v 1.1 2006/04/09 19:05:47 wiz Exp $
3
+
4
+ zip_get_file_comment.c -- get file comment
5
+ Copyright (C) 2006 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+
37
+
38
+ #include "zip.h"
39
+ #include "zipint.h"
40
+
41
+
42
+
43
+ const char *
44
+ zip_get_file_comment(struct zip *za, int idx, int *lenp, int flags)
45
+ {
46
+ if (idx < 0 || idx >= za->nentry) {
47
+ _zip_error_set(&za->error, ZIP_ER_INVAL, 0);
48
+ return NULL;
49
+ }
50
+
51
+ if ((flags & ZIP_FL_UNCHANGED)
52
+ || (za->entry[idx].ch_comment_len == -1)) {
53
+ if (lenp != NULL)
54
+ *lenp = za->cdir->entry[idx].comment_len;
55
+ return za->cdir->entry[idx].comment;
56
+ }
57
+
58
+ if (lenp != NULL)
59
+ *lenp = za->entry[idx].ch_comment_len;
60
+ return za->entry[idx].ch_comment;
61
+ }
@@ -0,0 +1,74 @@
1
+ /*
2
+ $NiH: zip_get_name.c,v 1.12 2004/11/30 23:02:46 wiz Exp $
3
+
4
+ zip_get_name.c -- get filename for a file in zip file
5
+ Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+
37
+
38
+ #include "zip.h"
39
+ #include "zipint.h"
40
+
41
+
42
+
43
+ const char *
44
+ zip_get_name(struct zip *za, int idx, int flags)
45
+ {
46
+ return _zip_get_name(za, idx, flags, &za->error);
47
+ }
48
+
49
+
50
+
51
+ const char *
52
+ _zip_get_name(struct zip *za, int idx, int flags, struct zip_error *error)
53
+ {
54
+ if (idx < 0 || idx >= za->nentry) {
55
+ _zip_error_set(error, ZIP_ER_INVAL, 0);
56
+ return NULL;
57
+ }
58
+
59
+ if ((flags & ZIP_FL_UNCHANGED) == 0) {
60
+ if (za->entry[idx].state == ZIP_ST_DELETED) {
61
+ _zip_error_set(error, ZIP_ER_DELETED, 0);
62
+ return NULL;
63
+ }
64
+ if (za->entry[idx].ch_filename)
65
+ return za->entry[idx].ch_filename;
66
+ }
67
+
68
+ if (za->cdir == NULL || idx >= za->cdir->nentry) {
69
+ _zip_error_set(error, ZIP_ER_INVAL, 0);
70
+ return NULL;
71
+ }
72
+
73
+ return za->cdir->entry[idx].filename;
74
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ $NiH: zip_get_num_files.c,v 1.1 2003/10/06 02:50:06 dillo Exp $
3
+
4
+ zip_get_num_files.c -- get number of files in archive
5
+ Copyright (C) 1999, 2003 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+
37
+
38
+ #include "zip.h"
39
+ #include "zipint.h"
40
+
41
+
42
+
43
+ int
44
+ zip_get_num_files(struct zip *za)
45
+ {
46
+ if (za == NULL)
47
+ return -1;
48
+
49
+ return za->nentry;
50
+ }
data/ext/zip_memdup.c ADDED
@@ -0,0 +1,58 @@
1
+ /*
2
+ $NiH: zip_memdup.c,v 1.1 2006/04/23 00:40:47 wiz Exp $
3
+
4
+ zip_memdup.c -- internal zip function, "strdup" with len
5
+ Copyright (C) 1999, 2003, 2004, 2005, 2006 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+ #include <stdlib.h>
37
+ #include <string.h>
38
+
39
+ #include "zip.h"
40
+ #include "zipint.h"
41
+
42
+
43
+
44
+ void *
45
+ _zip_memdup(const void *mem, size_t len, struct zip_error *error)
46
+ {
47
+ void *ret;
48
+
49
+ ret = malloc(len);
50
+ if (!ret) {
51
+ _zip_error_set(error, ZIP_ER_MEMORY, 0);
52
+ return NULL;
53
+ }
54
+
55
+ memcpy(ret, mem, len);
56
+
57
+ return ret;
58
+ }
@@ -0,0 +1,95 @@
1
+ /*
2
+ $NiH: zip_name_locate.c,v 1.18 2005/01/11 18:52:42 wiz Exp $
3
+
4
+ zip_name_locate.c -- get index by name
5
+ Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+
37
+
38
+ #include <string.h>
39
+
40
+ #ifdef _WIN32
41
+ #define strcasecmp _stricmp
42
+ #endif
43
+
44
+ #include "zip.h"
45
+ #include "zipint.h"
46
+
47
+
48
+
49
+ int
50
+ zip_name_locate(struct zip *za, const char *fname, int flags)
51
+ {
52
+ return _zip_name_locate(za, fname, flags, &za->error);
53
+ }
54
+
55
+
56
+
57
+ int
58
+ _zip_name_locate(struct zip *za, const char *fname, int flags,
59
+ struct zip_error *error)
60
+ {
61
+ int (*cmp)(const char *, const char *);
62
+ const char *fn, *p;
63
+ int i, n;
64
+
65
+ if (fname == NULL) {
66
+ _zip_error_set(error, ZIP_ER_INVAL, 0);
67
+ return -1;
68
+ }
69
+
70
+ cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
71
+
72
+ n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
73
+ for (i=0; i<n; i++) {
74
+ if (flags & ZIP_FL_UNCHANGED)
75
+ fn = za->cdir->entry[i].filename;
76
+ else
77
+ fn = _zip_get_name(za, i, flags, error);
78
+
79
+ /* newly added (partially filled) entry */
80
+ if (fn == NULL)
81
+ continue;
82
+
83
+ if (flags & ZIP_FL_NODIR) {
84
+ p = strrchr(fn, '/');
85
+ if (p)
86
+ fn = p+1;
87
+ }
88
+
89
+ if (cmp(fname, fn) == 0)
90
+ return i;
91
+ }
92
+
93
+ _zip_error_set(error, ZIP_ER_NOENT, 0);
94
+ return -1;
95
+ }
data/ext/zip_new.c ADDED
@@ -0,0 +1,71 @@
1
+ /*
2
+ $NiH: zip_new.c,v 1.11 2005/06/09 19:57:10 dillo Exp $
3
+
4
+ zip_new.c -- create and init struct zip
5
+ Copyright (C) 1999, 2004, 2005 Dieter Baron and Thomas Klausner
6
+
7
+ This file is part of libzip, a library to manipulate ZIP archives.
8
+ The authors can be contacted at <nih@giga.or.at>
9
+
10
+ Redistribution and use in source and binary forms, with or without
11
+ modification, are permitted provided that the following conditions
12
+ are met:
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+ 2. Redistributions in binary form must reproduce the above copyright
16
+ notice, this list of conditions and the following disclaimer in
17
+ the documentation and/or other materials provided with the
18
+ distribution.
19
+ 3. The names of the authors may not be used to endorse or promote
20
+ products derived from this software without specific prior
21
+ written permission.
22
+
23
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
+ */
35
+
36
+
37
+
38
+ #include <stdlib.h>
39
+ #include "zip.h"
40
+ #include "zipint.h"
41
+
42
+
43
+
44
+ /* _zip_new:
45
+ creates a new zipfile struct, and sets the contents to zero; returns
46
+ the new struct. */
47
+
48
+ struct zip *
49
+ _zip_new(struct zip_error *error)
50
+ {
51
+ struct zip *za;
52
+
53
+ za = (struct zip *)malloc(sizeof(struct zip));
54
+ if (!za) {
55
+ _zip_error_set(error, ZIP_ER_MEMORY, 0);
56
+ return NULL;
57
+ }
58
+
59
+ za->zn = NULL;
60
+ za->zp = NULL;
61
+ _zip_error_init(&za->error);
62
+ za->cdir = NULL;
63
+ za->ch_comment = NULL;
64
+ za->ch_comment_len = -1;
65
+ za->nentry = za->nentry_alloc = 0;
66
+ za->entry = NULL;
67
+ za->nfile = za->nfile_alloc = 0;
68
+ za->file = NULL;
69
+
70
+ return za;
71
+ }