libarchive-ruby-swig 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/libarchive-ruby-swig/entry.h +2 -5
- data/ext/libarchive-ruby-swig/error.cpp +30 -0
- data/ext/libarchive-ruby-swig/error.h +6 -0
- data/ext/libarchive-ruby-swig/libarchive.i +4 -0
- data/ext/libarchive-ruby-swig/reader.cpp +7 -7
- data/ext/libarchive-ruby-swig/reader.h +2 -5
- data/ext/libarchive-ruby-swig/writer.cpp +10 -10
- data/ext/libarchive-ruby-swig/writer.h +2 -5
- metadata +3 -2
@@ -281,11 +281,8 @@ class Entry
|
|
281
281
|
try {
|
282
282
|
$action
|
283
283
|
} catch(Error &err) {
|
284
|
-
|
285
|
-
|
286
|
-
rb_define_class_under(c_archive, "Error", rb_eStandardError);
|
287
|
-
static VALUE o_except = rb_exc_new2(e_archive, err.what());
|
288
|
-
rb_exc_raise(o_except);
|
284
|
+
Error::ruby_raise(err);
|
285
|
+
SWIG_fail;
|
289
286
|
}
|
290
287
|
}
|
291
288
|
#endif
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
This file is part of "libarchive-ruby-swig", a simple SWIG wrapper around
|
3
|
+
libarchive.
|
4
|
+
|
5
|
+
Copyright 2011, Tobias Koch <tobias.koch@gmail.com>
|
6
|
+
|
7
|
+
libarchive-ruby-swig is licensed under a simplified BSD License. A copy of the
|
8
|
+
license text can be found in the file LICENSE.txt distributed with the source.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#include <ruby.h>
|
12
|
+
#include "error.h"
|
13
|
+
|
14
|
+
namespace {
|
15
|
+
VALUE archive_rb_error_class;
|
16
|
+
}
|
17
|
+
|
18
|
+
void Error::init() throw()
|
19
|
+
{
|
20
|
+
VALUE c_archive = rb_define_module("Archive");
|
21
|
+
archive_rb_error_class =
|
22
|
+
rb_define_class_under(c_archive, "Error", rb_eStandardError);
|
23
|
+
}
|
24
|
+
|
25
|
+
void Error::ruby_raise(const Error &err) throw()
|
26
|
+
{
|
27
|
+
VALUE o_except = rb_exc_new2(archive_rb_error_class, err.what());
|
28
|
+
rb_exc_raise(o_except);
|
29
|
+
}
|
30
|
+
|
@@ -11,6 +11,9 @@
|
|
11
11
|
#ifndef CLASS_ARCHIVE_ERROR_H_INCLUDED
|
12
12
|
#define CLASS_ARCHIVE_ERROR_H_INCLUDED
|
13
13
|
|
14
|
+
/* NOTE: This file is not interpreted by SWIG */
|
15
|
+
|
16
|
+
#include <string>
|
14
17
|
#include <exception>
|
15
18
|
|
16
19
|
class Error: public std::exception
|
@@ -27,6 +30,9 @@ class Error: public std::exception
|
|
27
30
|
return error_msg.c_str();
|
28
31
|
}
|
29
32
|
|
33
|
+
static void init() throw();
|
34
|
+
static void ruby_raise(const Error &err) throw();
|
35
|
+
|
30
36
|
private:
|
31
37
|
|
32
38
|
std::string error_msg;
|
@@ -36,7 +36,7 @@ Reader::~Reader()
|
|
36
36
|
void Reader::close()
|
37
37
|
{
|
38
38
|
if(_ar) {
|
39
|
-
|
39
|
+
archive_read_free(_ar);
|
40
40
|
_ar = 0;
|
41
41
|
}
|
42
42
|
|
@@ -53,10 +53,10 @@ Reader *Reader::read_open_filename(const char *filename, const char *cmd, bool r
|
|
53
53
|
|
54
54
|
try {
|
55
55
|
if(cmd) {
|
56
|
-
if(
|
56
|
+
if(archive_read_support_filter_program(ar, cmd) != ARCHIVE_OK)
|
57
57
|
throw 0;
|
58
58
|
} else {
|
59
|
-
if(
|
59
|
+
if(archive_read_support_filter_all(ar) != ARCHIVE_OK)
|
60
60
|
throw 0;
|
61
61
|
}
|
62
62
|
|
@@ -73,7 +73,7 @@ Reader *Reader::read_open_filename(const char *filename, const char *cmd, bool r
|
|
73
73
|
|
74
74
|
} catch(...) {
|
75
75
|
std::string error_msg = archive_error_string(ar);
|
76
|
-
|
76
|
+
archive_read_free(ar);
|
77
77
|
throw Error(error_msg);
|
78
78
|
}
|
79
79
|
|
@@ -90,10 +90,10 @@ Reader *Reader::read_open_memory(const char *string, int length,
|
|
90
90
|
|
91
91
|
try {
|
92
92
|
if(cmd) {
|
93
|
-
if(
|
93
|
+
if(archive_read_support_filter_program(ar, cmd) != ARCHIVE_OK)
|
94
94
|
throw 0;
|
95
95
|
} else {
|
96
|
-
if(
|
96
|
+
if(archive_read_support_filter_all(ar) != ARCHIVE_OK)
|
97
97
|
throw 0;
|
98
98
|
}
|
99
99
|
|
@@ -110,7 +110,7 @@ Reader *Reader::read_open_memory(const char *string, int length,
|
|
110
110
|
|
111
111
|
} catch(...) {
|
112
112
|
std::string error_msg = archive_error_string(ar);
|
113
|
-
|
113
|
+
archive_read_free(ar);
|
114
114
|
free(content);
|
115
115
|
throw Error(error_msg);
|
116
116
|
}
|
@@ -34,11 +34,8 @@ class Reader
|
|
34
34
|
try {
|
35
35
|
$action
|
36
36
|
} catch(Error &err) {
|
37
|
-
|
38
|
-
|
39
|
-
rb_define_class_under(c_archive, "Error", rb_eStandardError);
|
40
|
-
static VALUE o_except = rb_exc_new2(e_archive, err.what());
|
41
|
-
rb_exc_raise(o_except);
|
37
|
+
Error::ruby_raise(err);
|
38
|
+
SWIG_fail;
|
42
39
|
}
|
43
40
|
}
|
44
41
|
#endif
|
@@ -35,7 +35,7 @@ Writer::~Writer()
|
|
35
35
|
void Writer::close()
|
36
36
|
{
|
37
37
|
if(_ar) {
|
38
|
-
|
38
|
+
archive_write_free(_ar);
|
39
39
|
_ar = 0;
|
40
40
|
}
|
41
41
|
}
|
@@ -48,7 +48,7 @@ Writer *Writer::write_open_filename(const char *filename,
|
|
48
48
|
std::string error_msg;
|
49
49
|
struct archive *ar = archive_write_new();
|
50
50
|
|
51
|
-
|
51
|
+
archive_write_add_filter_program(ar, cmd);
|
52
52
|
try {
|
53
53
|
set_format_helper(ar, format);
|
54
54
|
|
@@ -58,7 +58,7 @@ Writer *Writer::write_open_filename(const char *filename,
|
|
58
58
|
}
|
59
59
|
|
60
60
|
} catch(...) {
|
61
|
-
|
61
|
+
archive_write_free(ar);
|
62
62
|
throw;
|
63
63
|
}
|
64
64
|
|
@@ -76,22 +76,22 @@ Writer *Writer::write_open_filename(const char *filename,
|
|
76
76
|
|
77
77
|
switch(compression) {
|
78
78
|
case Archive::COMPRESSION_BZIP2:
|
79
|
-
|
79
|
+
archive_write_add_filter_bzip2(ar);
|
80
80
|
break;
|
81
81
|
case Archive::COMPRESSION_COMPRESS:
|
82
|
-
|
82
|
+
archive_write_add_filter_compress(ar);
|
83
83
|
break;
|
84
84
|
case Archive::COMPRESSION_GZIP:
|
85
|
-
|
85
|
+
archive_write_add_filter_gzip(ar);
|
86
86
|
break;
|
87
87
|
case Archive::COMPRESSION_LZMA:
|
88
|
-
|
88
|
+
archive_write_add_filter_lzma(ar);
|
89
89
|
break;
|
90
90
|
case Archive::COMPRESSION_NONE:
|
91
|
-
|
91
|
+
archive_write_add_filter_none(ar);
|
92
92
|
break;
|
93
93
|
case Archive::COMPRESSION_XZ:
|
94
|
-
|
94
|
+
archive_write_add_filter_xz(ar);
|
95
95
|
break;
|
96
96
|
default:
|
97
97
|
error_msg = "unknown or unsupported compression scheme";
|
@@ -106,7 +106,7 @@ Writer *Writer::write_open_filename(const char *filename,
|
|
106
106
|
}
|
107
107
|
|
108
108
|
} catch(...) {
|
109
|
-
|
109
|
+
archive_write_free(ar);
|
110
110
|
throw;
|
111
111
|
}
|
112
112
|
|
@@ -65,11 +65,8 @@ class Writer
|
|
65
65
|
try {
|
66
66
|
$action
|
67
67
|
} catch(Error &err) {
|
68
|
-
|
69
|
-
|
70
|
-
rb_define_class_under(c_archive, "Error", rb_eStandardError);
|
71
|
-
static VALUE o_except = rb_exc_new2(e_archive, err.what());
|
72
|
-
rb_exc_raise(o_except);
|
68
|
+
Error::ruby_raise(err);
|
69
|
+
SWIG_fail;
|
73
70
|
}
|
74
71
|
}
|
75
72
|
#endif
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libarchive-ruby-swig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby bindings to libarchive allowing reading and creation of compressed
|
15
15
|
archives in a variety of formats.
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- ext/libarchive-ruby-swig/stat.h
|
25
25
|
- ext/libarchive-ruby-swig/entry.cpp
|
26
26
|
- ext/libarchive-ruby-swig/entry.h
|
27
|
+
- ext/libarchive-ruby-swig/error.cpp
|
27
28
|
- ext/libarchive-ruby-swig/error.h
|
28
29
|
- ext/libarchive-ruby-swig/libarchive.i
|
29
30
|
- ext/libarchive-ruby-swig/reader.cpp
|