libarchive-ruby-swig 0.6.2 → 0.6.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c98f6a7357e2915fb16b63b73144982a19643f0e
4
+ data.tar.gz: a305c9b8fbd5ebb3bf0806f0ea1acb1f8192fda9
5
+ SHA512:
6
+ metadata.gz: 5912dea5f84918a2d60bad82460040b4f04e0a17fd08352b8221d62af49031f73a67c44ac1ce1c6e3fecdccf23b80ed8db787776c33b0593bfa4d08ab85c8cd4
7
+ data.tar.gz: 108b6cfbe75fdf22a11faf0c4025b4b456fe3db419a9cfc7341f0b6622dba911f1e2124593b410785ec4a4034d24a203e9865eca9946c15415cc24728442e6e4
@@ -30,7 +30,7 @@
30
30
  /* --- WRAPPER CODE START --- */
31
31
  %}
32
32
 
33
- %apply (char *STRING, int LENGTH) { (const char *string, int length) };
33
+ %apply (char *STRING, size_t LENGTH) { (const char *string, size_t length) };
34
34
 
35
35
  %include "stat.h"
36
36
  %include "reader.h"
@@ -81,11 +81,22 @@ Reader *Reader::read_open_filename(const char *filename, const char *cmd, bool r
81
81
  }
82
82
 
83
83
 
84
- Reader *Reader::read_open_memory(const char *string, int length,
84
+ Reader *Reader::read_open_memory(const char *string, size_t length,
85
85
  const char *cmd, bool raw)
86
86
  {
87
87
  struct archive *ar = archive_read_new();
88
+
89
+ if (!ar) {
90
+ throw Error("Unable to allocate libarchive handle!");
91
+ }
92
+
88
93
  char *content = (char*) malloc(length);
94
+
95
+ if (!content) {
96
+ archive_read_free(ar);
97
+ throw Error("Unable to allocate memory when duplicating buffer");
98
+ }
99
+
89
100
  memcpy((void*) content, (void*) string, length);
90
101
 
91
102
  try {
@@ -150,7 +161,7 @@ Entry *Reader::next_header()
150
161
  }
151
162
 
152
163
 
153
- VALUE Reader::read_data_helper(int len)
164
+ VALUE Reader::read_data_helper(size_t len)
154
165
  {
155
166
  std::string error_msg = "error while reading from archive";
156
167
 
@@ -44,18 +44,18 @@ class Reader
44
44
  %feature("autodoc", "Use <code>Archive::read_open_filename</code> instead") read_open_filename;
45
45
  %newobject read_open_filename(const char *filename, const char *cmd = 0, bool raw = false);
46
46
  %feature("autodoc", "Use <code>Archive::read_open_memory</code> instead") read_open_memory;
47
- %newobject read_open_memory(const char *string, int length, const char *cmd = 0, bool raw = false);
47
+ %newobject read_open_memory(const char *string, size_t length, const char *cmd = 0, bool raw = false);
48
48
  %feature("autodoc", "Returns the next Entry meta data object in the Archive") next_header;
49
49
  %newobject next_header();
50
50
  #endif
51
51
 
52
52
  static Reader *read_open_filename(const char *filename,
53
53
  const char *cmd = 0, bool raw = false);
54
- static Reader *read_open_memory(const char *string, int length,
54
+ static Reader *read_open_memory(const char *string, size_t length,
55
55
  const char *cmd = 0, bool raw = false);
56
56
 
57
57
  Entry *next_header();
58
- VALUE read_data_helper(int len);
58
+ VALUE read_data_helper(size_t len);
59
59
 
60
60
  #ifdef SWIG
61
61
  %exception;
@@ -64,7 +64,7 @@ class Reader
64
64
  private:
65
65
  struct archive *_ar;
66
66
  char *_buf;
67
- int _buf_size;
67
+ size_t _buf_size;
68
68
  char *_archive_content;
69
69
  };
70
70
 
@@ -17,18 +17,13 @@
17
17
  #include "error.h"
18
18
 
19
19
  Writer::Writer(struct archive *ar)
20
- :_ar(ar),
21
- _buf(0),
22
- _buf_size(0)
20
+ :_ar(ar)
23
21
  {}
24
22
 
25
23
 
26
24
  Writer::~Writer()
27
25
  {
28
26
  this->close();
29
- free(_buf);
30
- _buf = 0;
31
- _buf_size = 0;
32
27
  }
33
28
 
34
29
 
@@ -139,9 +134,9 @@ void Writer::write_header(Entry *entry)
139
134
  }
140
135
 
141
136
 
142
- void Writer::write_data_helper(const char *string, int length)
137
+ void Writer::write_data_helper(const char *string, size_t length)
143
138
  {
144
- if(archive_write_data(_ar, (void*) string, length) == -1) {
139
+ if(archive_write_data(_ar, (const void *) string, length) == -1) {
145
140
  std::string error_msg = archive_error_string(_ar);
146
141
  throw Error(error_msg);
147
142
  }
@@ -90,7 +90,7 @@ class Writer
90
90
  #endif
91
91
  void write_header(Entry *entry);
92
92
 
93
- void write_data_helper(const char *string, int length);
93
+ void write_data_helper(const char *string, size_t length);
94
94
 
95
95
  #ifdef SWIG
96
96
  %exception;
@@ -106,8 +106,6 @@ class Writer
106
106
  static void set_format_helper(struct archive *ar, int format);
107
107
 
108
108
  struct archive *_ar;
109
- char *_buf;
110
- int _buf_size;
111
109
 
112
110
  std::map<unsigned long, std::map<unsigned long, std::string> > _hardlinks;
113
111
  };
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libarchive-ruby-swig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
5
- prerelease:
4
+ version: 0.6.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tobias Koch
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-01 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Ruby bindings to libarchive allowing reading and creation of compressed
15
14
  archives in a variety of formats.
@@ -19,41 +18,40 @@ extensions:
19
18
  - ext/libarchive-ruby-swig/extconf.rb
20
19
  extra_rdoc_files: []
21
20
  files:
22
- - lib/libarchive_rs.rb
23
- - ext/libarchive-ruby-swig/stat.cpp
24
- - ext/libarchive-ruby-swig/stat.h
25
21
  - ext/libarchive-ruby-swig/entry.cpp
26
22
  - ext/libarchive-ruby-swig/entry.h
27
23
  - ext/libarchive-ruby-swig/error.cpp
28
24
  - ext/libarchive-ruby-swig/error.h
25
+ - ext/libarchive-ruby-swig/extconf.rb
29
26
  - ext/libarchive-ruby-swig/libarchive.i
30
27
  - ext/libarchive-ruby-swig/reader.cpp
31
28
  - ext/libarchive-ruby-swig/reader.h
29
+ - ext/libarchive-ruby-swig/stat.cpp
30
+ - ext/libarchive-ruby-swig/stat.h
32
31
  - ext/libarchive-ruby-swig/writer.cpp
33
32
  - ext/libarchive-ruby-swig/writer.h
34
- - ext/libarchive-ruby-swig/extconf.rb
33
+ - lib/libarchive_rs.rb
35
34
  homepage: http://libarchive-rs.rubyforge.org
36
35
  licenses: []
36
+ metadata: {}
37
37
  post_install_message:
38
38
  rdoc_options: []
39
39
  require_paths:
40
40
  - lib
41
41
  required_ruby_version: !ruby/object:Gem::Requirement
42
- none: false
43
42
  requirements:
44
- - - ! '>='
43
+ - - ">="
45
44
  - !ruby/object:Gem::Version
46
45
  version: '0'
47
46
  required_rubygems_version: !ruby/object:Gem::Requirement
48
- none: false
49
47
  requirements:
50
- - - ! '>='
48
+ - - ">="
51
49
  - !ruby/object:Gem::Version
52
50
  version: '0'
53
51
  requirements: []
54
52
  rubyforge_project: Libarchive/Ruby/SWIG
55
- rubygems_version: 1.8.23
53
+ rubygems_version: 2.2.2
56
54
  signing_key:
57
- specification_version: 3
55
+ specification_version: 4
58
56
  summary: Ruby bindings to libarchive
59
57
  test_files: []