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/ext/zip_err_str.c ADDED
@@ -0,0 +1,72 @@
1
+ /*
2
+ This file was generated automatically by ./make_zip_err_str.sh
3
+ from ./zip.h; make changes there.
4
+
5
+ NiH: make_zip_err_str.sh,v 1.7 2004/04/25 16:20:16 dillo Exp
6
+ NiH: zip.h,v 1.59 2006/10/04 15:21:09 dillo Exp
7
+ */
8
+
9
+ #include "zip.h"
10
+ #include "zipint.h"
11
+
12
+
13
+
14
+ const char * const _zip_err_str[] = {
15
+ "No error",
16
+ "Multi-disk zip archives not supported",
17
+ "Renaming temporary file failed",
18
+ "Closing zip archive failed",
19
+ "Seek error",
20
+ "Read error",
21
+ "Write error",
22
+ "CRC error",
23
+ "Containing zip archive was closed",
24
+ "No such file",
25
+ "File already exists",
26
+ "Can't open file",
27
+ "Failure to create temporary file",
28
+ "Zlib error",
29
+ "Malloc failure",
30
+ "Entry has been changed",
31
+ "Compression method not supported",
32
+ "Premature EOF",
33
+ "Invalid argument",
34
+ "Not a zip archive",
35
+ "Internal error",
36
+ "Zip archive inconsistent",
37
+ "Can't remove file",
38
+ "Entry has been deleted",
39
+ };
40
+
41
+ const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
42
+
43
+ #define N ZIP_ET_NONE
44
+ #define S ZIP_ET_SYS
45
+ #define Z ZIP_ET_ZLIB
46
+
47
+ const int _zip_err_type[] = {
48
+ N,
49
+ N,
50
+ S,
51
+ S,
52
+ S,
53
+ S,
54
+ S,
55
+ N,
56
+ N,
57
+ N,
58
+ N,
59
+ S,
60
+ S,
61
+ Z,
62
+ N,
63
+ N,
64
+ N,
65
+ N,
66
+ N,
67
+ N,
68
+ N,
69
+ N,
70
+ S,
71
+ N,
72
+ };
data/ext/zip_error.c ADDED
@@ -0,0 +1,104 @@
1
+ /*
2
+ $NiH: zip_error.c,v 1.7 2005/06/09 19:57:09 dillo Exp $
3
+
4
+ zip_error.c -- struct zip_error helper functions
5
+ Copyright (C) 1999-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 <stdlib.h>
39
+
40
+ #include "zip.h"
41
+ #include "zipint.h"
42
+
43
+
44
+
45
+ void
46
+ _zip_error_clear(struct zip_error *err)
47
+ {
48
+ err->zip_err = ZIP_ER_OK;
49
+ err->sys_err = 0;
50
+ }
51
+
52
+
53
+
54
+ void
55
+ _zip_error_copy(struct zip_error *dst, struct zip_error *src)
56
+ {
57
+ dst->zip_err = src->zip_err;
58
+ dst->sys_err = src->sys_err;
59
+ }
60
+
61
+
62
+
63
+ void
64
+ _zip_error_fini(struct zip_error *err)
65
+ {
66
+ free(err->str);
67
+ err->str = NULL;
68
+ }
69
+
70
+
71
+
72
+ void
73
+ _zip_error_get(struct zip_error *err, int *zep, int *sep)
74
+ {
75
+ if (zep)
76
+ *zep = err->zip_err;
77
+ if (sep) {
78
+ if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
79
+ *sep = err->sys_err;
80
+ else
81
+ *sep = 0;
82
+ }
83
+ }
84
+
85
+
86
+
87
+ void
88
+ _zip_error_init(struct zip_error *err)
89
+ {
90
+ err->zip_err = ZIP_ER_OK;
91
+ err->sys_err = 0;
92
+ err->str = NULL;
93
+ }
94
+
95
+
96
+
97
+ void
98
+ _zip_error_set(struct zip_error *err, int ze, int se)
99
+ {
100
+ if (err) {
101
+ err->zip_err = ze;
102
+ err->sys_err = se;
103
+ }
104
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ $NiH$
3
+
4
+ zip_error_clear.c -- clear zip error
5
+ Copyright (C) 1999-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
+ void
44
+ zip_error_clear(struct zip *za)
45
+ {
46
+ _zip_error_clear(&za->error);
47
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ $NiH: zip_error_get.c,v 1.1 2003/10/06 02:50:06 dillo Exp $
3
+
4
+ zip_error_get.c -- get zip error
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
+ void
44
+ zip_error_get(struct zip *za, int *zep, int *sep)
45
+ {
46
+ _zip_error_get(&za->error, zep, sep);
47
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ $NiH: zip_error_get_sys_type.c,v 1.1 2003/10/06 02:50:06 dillo Exp $
3
+
4
+ zip_error_get_sys_type.c -- return type of system error code
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_error_get_sys_type(int ze)
45
+ {
46
+ if (ze < 0 || ze >= _zip_nerr_str)
47
+ return 0;
48
+
49
+ return _zip_err_type[ze];
50
+ }
@@ -0,0 +1,93 @@
1
+ /*
2
+ $NiH: zip_error_strerror.c,v 1.4 2006/02/21 09:41:00 dillo Exp $
3
+
4
+ zip_error_sterror.c -- get string representation of struct zip_error
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 <errno.h>
39
+ #include <stdio.h>
40
+ #include <stdlib.h>
41
+ #include <string.h>
42
+
43
+ #include "zip.h"
44
+ #include "zipint.h"
45
+
46
+
47
+
48
+ const char *
49
+ _zip_error_strerror(struct zip_error *err)
50
+ {
51
+ const char *zs, *ss;
52
+ char buf[128], *s;
53
+
54
+ _zip_error_fini(err);
55
+
56
+ if (err->zip_err < 0 || err->zip_err >= _zip_nerr_str) {
57
+ sprintf(buf, "Unknown error %d", err->zip_err);
58
+ zs = NULL;
59
+ ss = buf;
60
+ }
61
+ else {
62
+ zs = _zip_err_str[err->zip_err];
63
+
64
+ switch (_zip_err_type[err->zip_err]) {
65
+ case ZIP_ET_SYS:
66
+ ss = strerror(err->sys_err);
67
+ break;
68
+
69
+ case ZIP_ET_ZLIB:
70
+ ss = zError(err->sys_err);
71
+ break;
72
+
73
+ default:
74
+ ss = NULL;
75
+ }
76
+ }
77
+
78
+ if (ss == NULL)
79
+ return zs;
80
+ else {
81
+ if ((s=(char *)malloc(strlen(ss)
82
+ + (zs ? strlen(zs)+2 : 0) + 1)) == NULL)
83
+ return _zip_err_str[ZIP_ER_MEMORY];
84
+
85
+ sprintf(s, "%s%s%s",
86
+ (zs ? zs : ""),
87
+ (zs ? ": " : ""),
88
+ ss);
89
+ err->str = s;
90
+
91
+ return s;
92
+ }
93
+ }
@@ -0,0 +1,77 @@
1
+ /*
2
+ $NiH: zip_error_to_str.c,v 1.4 2004/11/17 21:55:10 wiz Exp $
3
+
4
+ zip_error_to_str.c -- get string representation of zip error code
5
+ Copyright (C) 1999, 2003, 2004 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 <errno.h>
39
+ #include <stdio.h>
40
+ #include <stdlib.h>
41
+ #include <string.h>
42
+
43
+ #ifdef _WIN32
44
+ #define snprintf _snprintf
45
+ #endif
46
+
47
+ #include "zip.h"
48
+ #include "zipint.h"
49
+
50
+
51
+
52
+ int
53
+ zip_error_to_str(char *buf, size_t len, int ze, int se)
54
+ {
55
+ const char *zs, *ss;
56
+
57
+ if (ze < 0 || ze >= _zip_nerr_str)
58
+ return snprintf(buf, len, "Unknown error %d", ze);
59
+
60
+ zs = _zip_err_str[ze];
61
+
62
+ switch (_zip_err_type[ze]) {
63
+ case ZIP_ET_SYS:
64
+ ss = strerror(se);
65
+ break;
66
+
67
+ case ZIP_ET_ZLIB:
68
+ ss = zError(se);
69
+ break;
70
+
71
+ default:
72
+ ss = NULL;
73
+ }
74
+
75
+ return snprintf(buf, len, "%s%s%s",
76
+ zs, (ss ? ": " : ""), (ss ? ss : ""));
77
+ }
data/ext/zip_fclose.c ADDED
@@ -0,0 +1,74 @@
1
+ /*
2
+ $NiH: zip_fclose.c,v 1.13 2005/01/11 19:52:24 wiz Exp $
3
+
4
+ zip_fclose.c -- close file in zip archive
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
+
40
+ #include "zip.h"
41
+ #include "zipint.h"
42
+
43
+
44
+
45
+ int
46
+ zip_fclose(struct zip_file *zf)
47
+ {
48
+ int i, ret;
49
+
50
+ if (zf->zstr)
51
+ inflateEnd(zf->zstr);
52
+ free(zf->buffer);
53
+ free(zf->zstr);
54
+
55
+ for (i=0; i<zf->za->nfile; i++) {
56
+ if (zf->za->file[i] == zf) {
57
+ zf->za->file[i] = zf->za->file[zf->za->nfile-1];
58
+ zf->za->nfile--;
59
+ break;
60
+ }
61
+ }
62
+
63
+ ret = 0;
64
+ if (zf->error.zip_err)
65
+ ret = zf->error.zip_err;
66
+ else if ((zf->flags & ZIP_ZF_CRC) && (zf->flags & ZIP_ZF_EOF)) {
67
+ /* if EOF, compare CRC */
68
+ if (zf->crc_orig != zf->crc)
69
+ ret = ZIP_ER_CRC;
70
+ }
71
+
72
+ free(zf);
73
+ return ret;
74
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ $NiH: zip_file_error_clear.c,v 1.3 2006/10/04 18:26:42 dillo Exp $
3
+
4
+ zip_file_error_clear.c -- clear zip file error
5
+ Copyright (C) 1999-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
+ void
44
+ zip_file_error_clear(struct zip_file *zf)
45
+ {
46
+ _zip_error_clear(&zf->error);
47
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ $NiH: zip_file_error_get.c,v 1.1 2003/10/06 02:50:06 dillo Exp $
3
+
4
+ zip_file_error_get.c -- get zip file error
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
+ void
44
+ zip_file_error_get(struct zip_file *zf, int *zep, int *sep)
45
+ {
46
+ _zip_error_get(&zf->error, zep, sep);
47
+ }