ffi-libarchive 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e01bb3272bd5aa71fee1297906f261070a53ac2f
4
- data.tar.gz: a23a2a5397e9ef862509ecf96acc5d09effb6034
3
+ metadata.gz: 0ea648b9de61a77ffc0bd0535390428249e20294
4
+ data.tar.gz: 877ac8e2355a9ac7bd9e7a44fe53d6e805e64d1a
5
5
  SHA512:
6
- metadata.gz: b3e28ae4821dd3c1a68dfac5c984f2f07f0a8e78f75d7b94ef3dd3b15aeaf45312d0cd415f4277891257f4f238dd7b2951798bb140b9104b68d2a3f13644b000
7
- data.tar.gz: bcf010ccaa0b77c1a2d17a4aebfc85f9996aa15297ca172c759330e6f1c9ea26d622ef2f60f471d5208d15f0b25fa4e91e80370579cf78829d1122b5ea87fba4
6
+ metadata.gz: 7570c318020907c96aabeabea74c2be0047ea7ccdb919a83d12549d1435b19fa3279a3aa138344fb1be354e69d1a86f24a2c32c50c07c1666dc0a3c984e6f8b3
7
+ data.tar.gz: f8f148af7366d0c58251d04dfbc1f5f550b5d263b4dc4389cdeb712d390a38115cebee6e19324624259fb0fc1c09e871d0de487d8ef46118c25f4790897d2d31
data/.gitattributes ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile export-ignore
2
+ Thorfile export-ignore
3
+ Guardfile export-ignore
4
+ .gitattributes export-ignore
5
+ .gitignore export-ignore
6
+ .gitmodules export-ignore
data/.gitignore ADDED
@@ -0,0 +1,55 @@
1
+ # Ignore docs files
2
+ _gh_pages
3
+ _site
4
+ .ruby-version
5
+ .node-version
6
+ Gemfile.lock
7
+ pkg/
8
+
9
+ # Numerous always-ignore extensions
10
+ *.diff
11
+ *.err
12
+ *.orig
13
+ *.log
14
+ *.rej
15
+ *.swo
16
+ *.swp
17
+ *.zip
18
+ *.vi
19
+ *~
20
+
21
+ # OS or Editor folders
22
+ .DS_Store
23
+ ._*
24
+ Thumbs.db
25
+ .cache
26
+ .project
27
+ .settings
28
+ .tmproj
29
+ *.esproj
30
+ nbproject
31
+ *.sublime-project
32
+ *.sublime-workspace
33
+ .idea
34
+
35
+ # Komodo
36
+ *.komodoproject
37
+ .komodotools
38
+
39
+ # grunt-html-validation
40
+ validation-status.json
41
+ validation-report.json
42
+
43
+ # Folders to ignore
44
+ bin
45
+ node_modules
46
+ tmp
47
+ vendor
48
+ .bundle
49
+
50
+ # Chef specifics to ignore
51
+ .chef
52
+ .chefdk
53
+ .kitchen
54
+ .vagrant
55
+ Berksfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,41 @@
1
+ ---
2
+ AlignParameters:
3
+ Enabled: false
4
+
5
+ Encoding:
6
+ Enabled: false
7
+
8
+ ClassLength:
9
+ Enabled: false
10
+
11
+ MethodLength:
12
+ Enabled: false
13
+
14
+ LineLength:
15
+ Enabled: false
16
+
17
+ Documentation:
18
+ Enabled: false
19
+
20
+ PerceivedComplexity:
21
+ Enabled: false
22
+
23
+ CyclomaticComplexity:
24
+ Enabled: false
25
+
26
+ Style/FileName:
27
+ Enabled: false
28
+
29
+ Style/ClassAndModuleChildren:
30
+ Enabled: false
31
+
32
+ Metrics/AbcSize:
33
+ Enabled: false
34
+
35
+ AllCops:
36
+ Exclude:
37
+ - 'Guardfile'
38
+ - 'test/**/*_spec.rb'
39
+
40
+ Style/GuardClause:
41
+ Enabled: false
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ --plugin classmethods
2
+ --embed-mixin ClassMethods
3
+ --hide-api private
4
+ --markup markdown
5
+ --hide-void-return
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :lint do
5
+ gem 'rubocop'
6
+ end
7
+
8
+ group :doc do
9
+ gem 'yard'
10
+ end
data/README.md CHANGED
@@ -1,70 +1,12 @@
1
1
  ffi-libarchive
2
2
  ==============
3
+ A Ruby FFI binding to [libarchive][0].
3
4
 
4
- An ffi binding to libarchive.
5
+ This library provides Ruby FFI bindings to the well-known
6
+ [libarchive library][0]. It aims to be interface compatiable
7
+ to libarchive-ruby.
5
8
 
6
- This library provides ruby-bindings to the well-known
7
- [libarchive](http://code.google.com/p/libarchive/) library. It should be interface-compatible to libarchive-ruby and libarchive-ruby-swig gems.
9
+ ## Why this instead of libarchive-ruby?
8
10
 
9
- Why another binding? Because I often work on workstations without
10
- development libraries of libarchive installed. An FFI-based gem allows
11
- to use the library without the hassle of compiling native extensions.
12
-
13
- Note that this is not completely true for this library. Two methods,
14
- ``Entry::copy_stat`` and ``Entry::copy_lstat`` require a small native
15
- extension through ``ffi-inliner``, though this does not require
16
- development files of libarchive but only of libc.
17
-
18
- Features
19
- --------
20
-
21
- * Compatible interface to libarchive-ruby Entry::copy_lstat and
22
- * Entry::copy_stat require ffi-inliner because of the platform
23
- dependence of stat() and lstat() functions of libc
24
-
25
- Examples
26
- --------
27
-
28
- require 'ffi-libarchive'
29
-
30
- Requirements
31
- ------------
32
-
33
- * ``ffi`` >= 1.0.0
34
- * ``ffi-inliner`` for ``Entry::copy_lstat`` and ``Entry::copy_stat``
35
-
36
- Install
37
- -------
38
-
39
- * gem install ffi-libarchive
40
-
41
- Author
42
- ------
43
-
44
- Original author: Frank Fischer
45
-
46
- License
47
- -------
48
-
49
- (The MIT License)
50
-
51
- Copyright (c) 2011 Frank Fischer
52
-
53
- Permission is hereby granted, free of charge, to any person obtaining
54
- a copy of this software and associated documentation files (the
55
- 'Software'), to deal in the Software without restriction, including
56
- without limitation the rights to use, copy, modify, merge, publish,
57
- distribute, sublicense, and/or sell copies of the Software, and to
58
- permit persons to whom the Software is furnished to do so, subject to
59
- the following conditions:
60
-
61
- The above copyright notice and this permission notice shall be
62
- included in all copies or substantial portions of the Software.
63
-
64
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
65
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
67
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
68
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
69
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
70
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+ [0]: https://github.com/libarchive/libarchive
12
+ [1]: https://github.com/Hanmac/libarchive-ruby
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rspec_opts = [
6
+ '--color',
7
+ '--format progress',
8
+ ].join(' ')
9
+ end
10
+
11
+ task default: :spec
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ffi-libarchive/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'ffi-libarchive'
8
+ s.version = Archive::VERSION
9
+ s.authors = ['John Bellone', 'Jamie Winsor', 'Frank Fischer']
10
+ s.email = %w{jbellone@bloomberg.net jamie@vialstudios.com frank-fischer@shadow-soft.de}
11
+ s.description = 'A Ruby FFI binding to libarchive.'
12
+ s.summary = s.description
13
+ s.homepage = 'https://github.com/johnbellone/ffi-libarchive'
14
+ s.license = 'GPL 3.0'
15
+
16
+ s.files = `git ls-files`.split($/)
17
+ s.test_files = s.files.grep(%r{^(test)/})
18
+ s.require_paths = %w{lib}
19
+ s.required_ruby_version = '>= 1.9'
20
+
21
+ s.add_dependency 'ffi', '~> 1.0'
22
+
23
+ s.add_development_dependency 'bundler'
24
+ s.add_development_dependency 'rake'
25
+ end
@@ -1,10 +1,7 @@
1
-
2
1
  module Archive
3
-
4
2
  # :stopdoc:
5
3
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
4
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
- VERSION = ::File.read(PATH + 'version.txt').strip
8
5
  # :startdoc:
9
6
 
10
7
  # Returns the library path for the module. If any arguments are given,
@@ -60,5 +57,3 @@ require File.join(Archive::LIBPATH, "ffi-libarchive", "archive")
60
57
  require File.join(Archive::LIBPATH, "ffi-libarchive", "reader")
61
58
  require File.join(Archive::LIBPATH, "ffi-libarchive", "writer")
62
59
  require File.join(Archive::LIBPATH, "ffi-libarchive", "entry")
63
-
64
-
@@ -2,299 +2,299 @@ require 'ffi'
2
2
 
3
3
  module Archive
4
4
 
5
- module C
6
- def self.attach_function_maybe *args
7
- attach_function(*args)
8
- rescue FFI::NotFoundError
9
- end
5
+ module C
6
+ def self.attach_function_maybe *args
7
+ attach_function(*args)
8
+ rescue FFI::NotFoundError
9
+ end
10
10
 
11
- extend FFI::Library
12
- ffi_lib ["archive", "libarchive.so.2"]
11
+ extend FFI::Library
12
+ ffi_lib ["archive", "libarchive.so.2"]
13
13
 
14
- attach_function :archive_version_number, [], :int
15
- attach_function :archive_version_string, [], :string
16
- attach_function :archive_error_string, [:pointer], :string
17
- attach_function :archive_errno, [:pointer], :int
14
+ attach_function :archive_version_number, [], :int
15
+ attach_function :archive_version_string, [], :string
16
+ attach_function :archive_error_string, [:pointer], :string
17
+ attach_function :archive_errno, [:pointer], :int
18
18
 
19
- attach_function :archive_read_new, [], :pointer
20
- attach_function :archive_read_open_filename, [:pointer, :string, :size_t], :int
21
- attach_function :archive_read_open_memory, [:pointer, :pointer, :size_t], :int
22
- attach_function :archive_read_support_compression_program, [:pointer, :string], :int
23
- attach_function :archive_read_support_compression_all, [:pointer], :int
24
- attach_function :archive_read_support_format_all, [:pointer], :int
25
- # TODO: this function has been renamed to :archive_read_free in libarchive 3.0
26
- attach_function :archive_read_finish, [:pointer], :int
27
- attach_function :archive_read_extract, [:pointer, :pointer, :int], :int
28
- attach_function :archive_read_header_position, [:pointer], :int
29
- attach_function :archive_read_next_header, [:pointer, :pointer], :int
30
- attach_function :archive_read_data, [:pointer, :pointer, :size_t], :size_t
31
- attach_function :archive_read_data_into_fd, [:pointer, :int], :int
19
+ attach_function :archive_read_new, [], :pointer
20
+ attach_function :archive_read_open_filename, [:pointer, :string, :size_t], :int
21
+ attach_function :archive_read_open_memory, [:pointer, :pointer, :size_t], :int
22
+ attach_function :archive_read_support_compression_program, [:pointer, :string], :int
23
+ attach_function :archive_read_support_compression_all, [:pointer], :int
24
+ attach_function :archive_read_support_format_all, [:pointer], :int
25
+ # TODO: this function has been renamed to :archive_read_free in libarchive 3.0
26
+ attach_function :archive_read_finish, [:pointer], :int
27
+ attach_function :archive_read_extract, [:pointer, :pointer, :int], :int
28
+ attach_function :archive_read_header_position, [:pointer], :int
29
+ attach_function :archive_read_next_header, [:pointer, :pointer], :int
30
+ attach_function :archive_read_data, [:pointer, :pointer, :size_t], :size_t
31
+ attach_function :archive_read_data_into_fd, [:pointer, :int], :int
32
32
 
33
- attach_function :archive_write_new, [], :pointer
34
- attach_function :archive_write_open_filename, [:pointer, :string], :int
35
- callback :archive_open_callback, [:pointer, :pointer], :int
36
- callback :archive_write_callback, [:pointer, :pointer, :pointer, :size_t], :int
37
- callback :archive_close_callback, [:pointer, :pointer], :int
38
- # TODO: the following function is the real definition but uses multiple callbacks. This implies that it will not work with Rubinius (currently), but luckily we only need the write-callback actually.
39
- #attach_function :archive_write_open, [:pointer, :pointer, :archive_open_callback, :archive_write_callback, :archive_close_callback], :int
40
- attach_function :archive_write_open, [:pointer, :pointer, :pointer, :archive_write_callback, :pointer], :int
41
- # TODO: catch errors if not defined
42
- attach_function :archive_write_set_compression_none, [:pointer], :int
43
- attach_function_maybe :archive_write_set_compression_gzip, [:pointer], :int
44
- attach_function_maybe :archive_write_set_compression_bzip2, [:pointer], :int
45
- attach_function_maybe :archive_write_set_compression_compress, [:pointer], :int
46
- attach_function_maybe :archive_write_set_compression_lzma, [:pointer], :int
47
- attach_function_maybe :archive_write_set_compression_xz, [:pointer], :int
48
- attach_function :archive_write_set_compression_program, [:pointer, :string], :int
33
+ attach_function :archive_write_new, [], :pointer
34
+ attach_function :archive_write_open_filename, [:pointer, :string], :int
35
+ callback :archive_open_callback, [:pointer, :pointer], :int
36
+ callback :archive_write_callback, [:pointer, :pointer, :pointer, :size_t], :int
37
+ callback :archive_close_callback, [:pointer, :pointer], :int
38
+ # TODO: the following function is the real definition but uses multiple callbacks. This implies that it will not work with Rubinius (currently), but luckily we only need the write-callback actually.
39
+ #attach_function :archive_write_open, [:pointer, :pointer, :archive_open_callback, :archive_write_callback, :archive_close_callback], :int
40
+ attach_function :archive_write_open, [:pointer, :pointer, :pointer, :archive_write_callback, :pointer], :int
41
+ # TODO: catch errors if not defined
42
+ attach_function :archive_write_set_compression_none, [:pointer], :int
43
+ attach_function_maybe :archive_write_set_compression_gzip, [:pointer], :int
44
+ attach_function_maybe :archive_write_set_compression_bzip2, [:pointer], :int
45
+ attach_function_maybe :archive_write_set_compression_compress, [:pointer], :int
46
+ attach_function_maybe :archive_write_set_compression_lzma, [:pointer], :int
47
+ attach_function_maybe :archive_write_set_compression_xz, [:pointer], :int
48
+ attach_function :archive_write_set_compression_program, [:pointer, :string], :int
49
49
 
50
- def self.archive_write_set_compression(archive, compression)
51
- case compression
52
- when String
53
- archive_write_set_compression_program archive, compression
54
- when COMPRESSION_BZIP2
55
- archive_write_set_compression_bzip2 archive
56
- when COMPRESSION_GZIP
57
- archive_write_set_compression_gzip archive
58
- when COMPRESSION_LZMA
59
- archive_write_set_compression_lzma archive
60
- when COMPRESSION_XZ
61
- archive_write_set_compression_xz archive
62
- when COMPRESSION_COMPRESS
63
- archive_write_set_compression_compress archive
64
- when COMPRESSION_NONE
65
- archive_write_set_compression_none archive
66
- else
67
- raise "Unknown compression type: #{compression}"
68
- end
69
- end
50
+ def self.archive_write_set_compression(archive, compression)
51
+ case compression
52
+ when String
53
+ archive_write_set_compression_program archive, compression
54
+ when COMPRESSION_BZIP2
55
+ archive_write_set_compression_bzip2 archive
56
+ when COMPRESSION_GZIP
57
+ archive_write_set_compression_gzip archive
58
+ when COMPRESSION_LZMA
59
+ archive_write_set_compression_lzma archive
60
+ when COMPRESSION_XZ
61
+ archive_write_set_compression_xz archive
62
+ when COMPRESSION_COMPRESS
63
+ archive_write_set_compression_compress archive
64
+ when COMPRESSION_NONE
65
+ archive_write_set_compression_none archive
66
+ else
67
+ raise "Unknown compression type: #{compression}"
68
+ end
69
+ end
70
70
 
71
- attach_function :archive_write_set_format, [:pointer, :int], :int
72
- attach_function :archive_write_data, [:pointer, :pointer, :size_t], :ssize_t
73
- attach_function :archive_write_header, [:pointer, :pointer], :int
74
- attach_function :archive_write_finish, [:pointer], :void
75
- attach_function :archive_write_get_bytes_in_last_block, [:pointer], :int
76
- attach_function :archive_write_set_bytes_in_last_block, [:pointer, :int], :int
71
+ attach_function :archive_write_set_format, [:pointer, :int], :int
72
+ attach_function :archive_write_data, [:pointer, :pointer, :size_t], :ssize_t
73
+ attach_function :archive_write_header, [:pointer, :pointer], :int
74
+ attach_function :archive_write_finish, [:pointer], :void
75
+ attach_function :archive_write_get_bytes_in_last_block, [:pointer], :int
76
+ attach_function :archive_write_set_bytes_in_last_block, [:pointer, :int], :int
77
77
 
78
- attach_function :archive_entry_new, [], :pointer
79
- attach_function :archive_entry_free, [:pointer], :void
80
- attach_function :archive_entry_atime, [:pointer], :time_t
81
- attach_function :archive_entry_atime_nsec, [:pointer, :time_t, :long], :void
82
- attach_function_maybe :archive_entry_atime_is_set, [:pointer], :int
83
- attach_function :archive_entry_set_atime, [:pointer, :time_t, :long], :int
84
- attach_function_maybe :archive_entry_unset_atime, [:pointer], :int
85
- attach_function_maybe :archive_entry_birthtime, [:pointer], :time_t
86
- attach_function_maybe :archive_entry_birthtime_nsec, [:pointer, :time_t, :long], :void
87
- attach_function_maybe :archive_entry_birthtime_is_set, [:pointer], :int
88
- attach_function_maybe :archive_entry_set_birthtime, [:pointer, :time_t, :long], :int
89
- attach_function_maybe :archive_entry_unset_birthtime, [:pointer], :int
90
- attach_function :archive_entry_ctime, [:pointer], :time_t
91
- attach_function :archive_entry_ctime_nsec, [:pointer, :time_t, :long], :void
92
- attach_function_maybe :archive_entry_ctime_is_set, [:pointer], :int
93
- attach_function :archive_entry_set_ctime, [:pointer, :time_t, :long], :int
94
- attach_function_maybe :archive_entry_unset_ctime, [:pointer], :int
95
- attach_function :archive_entry_mtime, [:pointer], :time_t
96
- attach_function :archive_entry_mtime_nsec, [:pointer, :time_t, :long], :void
97
- attach_function_maybe :archive_entry_mtime_is_set, [:pointer], :int
98
- attach_function :archive_entry_set_mtime, [:pointer, :time_t, :long], :int
99
- attach_function_maybe :archive_entry_unset_mtime, [:pointer], :int
100
- attach_function :archive_entry_dev, [:pointer], :dev_t
101
- attach_function :archive_entry_set_dev, [:pointer, :dev_t], :void
102
- attach_function :archive_entry_devmajor, [:pointer], :dev_t
103
- attach_function :archive_entry_set_devmajor, [:pointer, :dev_t], :void
104
- attach_function :archive_entry_devminor, [:pointer], :dev_t
105
- attach_function :archive_entry_set_devminor, [:pointer, :dev_t], :void
106
- attach_function :archive_entry_filetype, [:pointer], :mode_t
107
- attach_function :archive_entry_set_filetype, [:pointer, :mode_t], :void
108
- attach_function :archive_entry_fflags, [:pointer, :pointer, :pointer], :void
109
- attach_function :archive_entry_set_fflags, [:pointer, :ulong, :ulong], :void
110
- attach_function :archive_entry_fflags_text, [:pointer], :string
111
- attach_function :archive_entry_gid, [:pointer], :gid_t
112
- attach_function :archive_entry_set_gid, [:pointer, :gid_t], :void
113
- attach_function :archive_entry_gname, [:pointer], :string
114
- attach_function :archive_entry_set_gname, [:pointer, :string], :void
115
- attach_function :archive_entry_hardlink, [:pointer], :string
116
- attach_function :archive_entry_set_hardlink, [:pointer, :string], :void
117
- attach_function :archive_entry_set_link, [:pointer, :string], :void
118
- attach_function :archive_entry_ino, [:pointer], :ino_t
119
- attach_function :archive_entry_set_ino, [:pointer, :ino_t], :void
120
- attach_function :archive_entry_mode, [:pointer], :mode_t
121
- attach_function :archive_entry_set_mode, [:pointer, :mode_t], :void
122
- attach_function :archive_entry_set_perm, [:pointer, :mode_t], :void
123
- attach_function :archive_entry_nlink, [:pointer], :uint
124
- attach_function :archive_entry_set_nlink, [:pointer, :uint], :void
125
- attach_function :archive_entry_pathname, [:pointer], :string
126
- attach_function :archive_entry_set_pathname, [:pointer, :string], :void
127
- attach_function :archive_entry_rdev, [:pointer], :dev_t
128
- attach_function :archive_entry_set_rdev, [:pointer, :dev_t], :void
129
- attach_function :archive_entry_rdevmajor, [:pointer], :dev_t
130
- attach_function :archive_entry_set_rdevmajor, [:pointer, :dev_t], :void
131
- attach_function :archive_entry_rdevminor, [:pointer], :dev_t
132
- attach_function :archive_entry_set_rdevminor, [:pointer, :dev_t], :void
133
- attach_function :archive_entry_size, [:pointer], :int64_t
134
- attach_function :archive_entry_set_size, [:pointer, :int64_t], :void
135
- attach_function_maybe :archive_entry_unset_size, [:pointer], :void
136
- attach_function_maybe :archive_entry_size_is_set, [:pointer], :int
137
- attach_function :archive_entry_sourcepath, [:pointer], :string
138
- attach_function :archive_entry_strmode, [:pointer], :string
139
- attach_function :archive_entry_symlink, [:pointer], :string
140
- attach_function :archive_entry_set_symlink, [:pointer, :string], :void
141
- attach_function :archive_entry_uid, [:pointer], :uid_t
142
- attach_function :archive_entry_set_uid, [:pointer, :uid_t], :void
143
- attach_function :archive_entry_uname, [:pointer], :string
144
- attach_function :archive_entry_set_uname, [:pointer, :string], :void
145
- attach_function :archive_entry_copy_stat, [:pointer, :pointer], :void
146
- attach_function :archive_entry_copy_fflags_text, [:pointer, :string], :string
147
- attach_function :archive_entry_copy_gname, [:pointer, :string], :string
148
- attach_function :archive_entry_copy_uname, [:pointer, :string], :string
149
- attach_function :archive_entry_copy_hardlink, [:pointer, :string], :string
150
- attach_function :archive_entry_copy_link, [:pointer, :string], :string
151
- attach_function :archive_entry_copy_symlink, [:pointer, :string], :string
152
- attach_function :archive_entry_copy_sourcepath, [:pointer, :string], :string
153
- attach_function :archive_entry_copy_pathname, [:pointer, :string], :string
154
- attach_function :archive_entry_xattr_clear, [:pointer], :void
155
- attach_function :archive_entry_xattr_add_entry, [:pointer, :string, :pointer, :size_t], :void
156
- attach_function :archive_entry_xattr_count, [:pointer], :int
157
- attach_function :archive_entry_xattr_reset, [:pointer], :int
158
- attach_function :archive_entry_xattr_next, [:pointer, :pointer, :pointer, :pointer], :int
78
+ attach_function :archive_entry_new, [], :pointer
79
+ attach_function :archive_entry_free, [:pointer], :void
80
+ attach_function :archive_entry_atime, [:pointer], :time_t
81
+ attach_function :archive_entry_atime_nsec, [:pointer, :time_t, :long], :void
82
+ attach_function_maybe :archive_entry_atime_is_set, [:pointer], :int
83
+ attach_function :archive_entry_set_atime, [:pointer, :time_t, :long], :int
84
+ attach_function_maybe :archive_entry_unset_atime, [:pointer], :int
85
+ attach_function_maybe :archive_entry_birthtime, [:pointer], :time_t
86
+ attach_function_maybe :archive_entry_birthtime_nsec, [:pointer, :time_t, :long], :void
87
+ attach_function_maybe :archive_entry_birthtime_is_set, [:pointer], :int
88
+ attach_function_maybe :archive_entry_set_birthtime, [:pointer, :time_t, :long], :int
89
+ attach_function_maybe :archive_entry_unset_birthtime, [:pointer], :int
90
+ attach_function :archive_entry_ctime, [:pointer], :time_t
91
+ attach_function :archive_entry_ctime_nsec, [:pointer, :time_t, :long], :void
92
+ attach_function_maybe :archive_entry_ctime_is_set, [:pointer], :int
93
+ attach_function :archive_entry_set_ctime, [:pointer, :time_t, :long], :int
94
+ attach_function_maybe :archive_entry_unset_ctime, [:pointer], :int
95
+ attach_function :archive_entry_mtime, [:pointer], :time_t
96
+ attach_function :archive_entry_mtime_nsec, [:pointer, :time_t, :long], :void
97
+ attach_function_maybe :archive_entry_mtime_is_set, [:pointer], :int
98
+ attach_function :archive_entry_set_mtime, [:pointer, :time_t, :long], :int
99
+ attach_function_maybe :archive_entry_unset_mtime, [:pointer], :int
100
+ attach_function :archive_entry_dev, [:pointer], :dev_t
101
+ attach_function :archive_entry_set_dev, [:pointer, :dev_t], :void
102
+ attach_function :archive_entry_devmajor, [:pointer], :dev_t
103
+ attach_function :archive_entry_set_devmajor, [:pointer, :dev_t], :void
104
+ attach_function :archive_entry_devminor, [:pointer], :dev_t
105
+ attach_function :archive_entry_set_devminor, [:pointer, :dev_t], :void
106
+ attach_function :archive_entry_filetype, [:pointer], :mode_t
107
+ attach_function :archive_entry_set_filetype, [:pointer, :mode_t], :void
108
+ attach_function :archive_entry_fflags, [:pointer, :pointer, :pointer], :void
109
+ attach_function :archive_entry_set_fflags, [:pointer, :ulong, :ulong], :void
110
+ attach_function :archive_entry_fflags_text, [:pointer], :string
111
+ attach_function :archive_entry_gid, [:pointer], :gid_t
112
+ attach_function :archive_entry_set_gid, [:pointer, :gid_t], :void
113
+ attach_function :archive_entry_gname, [:pointer], :string
114
+ attach_function :archive_entry_set_gname, [:pointer, :string], :void
115
+ attach_function :archive_entry_hardlink, [:pointer], :string
116
+ attach_function :archive_entry_set_hardlink, [:pointer, :string], :void
117
+ attach_function :archive_entry_set_link, [:pointer, :string], :void
118
+ attach_function :archive_entry_ino, [:pointer], :ino_t
119
+ attach_function :archive_entry_set_ino, [:pointer, :ino_t], :void
120
+ attach_function :archive_entry_mode, [:pointer], :mode_t
121
+ attach_function :archive_entry_set_mode, [:pointer, :mode_t], :void
122
+ attach_function :archive_entry_set_perm, [:pointer, :mode_t], :void
123
+ attach_function :archive_entry_nlink, [:pointer], :uint
124
+ attach_function :archive_entry_set_nlink, [:pointer, :uint], :void
125
+ attach_function :archive_entry_pathname, [:pointer], :string
126
+ attach_function :archive_entry_set_pathname, [:pointer, :string], :void
127
+ attach_function :archive_entry_rdev, [:pointer], :dev_t
128
+ attach_function :archive_entry_set_rdev, [:pointer, :dev_t], :void
129
+ attach_function :archive_entry_rdevmajor, [:pointer], :dev_t
130
+ attach_function :archive_entry_set_rdevmajor, [:pointer, :dev_t], :void
131
+ attach_function :archive_entry_rdevminor, [:pointer], :dev_t
132
+ attach_function :archive_entry_set_rdevminor, [:pointer, :dev_t], :void
133
+ attach_function :archive_entry_size, [:pointer], :int64_t
134
+ attach_function :archive_entry_set_size, [:pointer, :int64_t], :void
135
+ attach_function_maybe :archive_entry_unset_size, [:pointer], :void
136
+ attach_function_maybe :archive_entry_size_is_set, [:pointer], :int
137
+ attach_function :archive_entry_sourcepath, [:pointer], :string
138
+ attach_function :archive_entry_strmode, [:pointer], :string
139
+ attach_function :archive_entry_symlink, [:pointer], :string
140
+ attach_function :archive_entry_set_symlink, [:pointer, :string], :void
141
+ attach_function :archive_entry_uid, [:pointer], :uid_t
142
+ attach_function :archive_entry_set_uid, [:pointer, :uid_t], :void
143
+ attach_function :archive_entry_uname, [:pointer], :string
144
+ attach_function :archive_entry_set_uname, [:pointer, :string], :void
145
+ attach_function :archive_entry_copy_stat, [:pointer, :pointer], :void
146
+ attach_function :archive_entry_copy_fflags_text, [:pointer, :string], :string
147
+ attach_function :archive_entry_copy_gname, [:pointer, :string], :string
148
+ attach_function :archive_entry_copy_uname, [:pointer, :string], :string
149
+ attach_function :archive_entry_copy_hardlink, [:pointer, :string], :string
150
+ attach_function :archive_entry_copy_link, [:pointer, :string], :string
151
+ attach_function :archive_entry_copy_symlink, [:pointer, :string], :string
152
+ attach_function :archive_entry_copy_sourcepath, [:pointer, :string], :string
153
+ attach_function :archive_entry_copy_pathname, [:pointer, :string], :string
154
+ attach_function :archive_entry_xattr_clear, [:pointer], :void
155
+ attach_function :archive_entry_xattr_add_entry, [:pointer, :string, :pointer, :size_t], :void
156
+ attach_function :archive_entry_xattr_count, [:pointer], :int
157
+ attach_function :archive_entry_xattr_reset, [:pointer], :int
158
+ attach_function :archive_entry_xattr_next, [:pointer, :pointer, :pointer, :pointer], :int
159
159
 
160
- EOF = 1
161
- OK = 0
162
- RETRY = (-10)
163
- WARN = (-20)
164
- FAILED = (-25)
165
- FATAL = (-30)
160
+ EOF = 1
161
+ OK = 0
162
+ RETRY = (-10)
163
+ WARN = (-20)
164
+ FAILED = (-25)
165
+ FATAL = (-30)
166
166
 
167
- DATA_BUFFER_SIZE = 2**16
168
- end
167
+ DATA_BUFFER_SIZE = 2**16
168
+ end
169
169
 
170
- COMPRESSION_NONE = 0
171
- COMPRESSION_GZIP = 1
172
- COMPRESSION_BZIP2 = 2
173
- COMPRESSION_COMPRESS = 3
174
- COMPRESSION_PROGRAM = 4
175
- COMPRESSION_LZMA = 5
176
- COMPRESSION_XZ = 6
177
- COMPRESSION_UU = 7
178
- COMPRESSION_RPM = 8
170
+ COMPRESSION_NONE = 0
171
+ COMPRESSION_GZIP = 1
172
+ COMPRESSION_BZIP2 = 2
173
+ COMPRESSION_COMPRESS = 3
174
+ COMPRESSION_PROGRAM = 4
175
+ COMPRESSION_LZMA = 5
176
+ COMPRESSION_XZ = 6
177
+ COMPRESSION_UU = 7
178
+ COMPRESSION_RPM = 8
179
179
 
180
- FORMAT_BASE_MASK = 0xff0000
181
- FORMAT_CPIO = 0x10000
182
- FORMAT_CPIO_POSIX = (FORMAT_CPIO | 1)
183
- FORMAT_CPIO_BIN_LE = (FORMAT_CPIO | 2)
184
- FORMAT_CPIO_BIN_BE = (FORMAT_CPIO | 3)
185
- FORMAT_CPIO_SVR4_NOCRC = (FORMAT_CPIO | 4)
186
- FORMAT_CPIO_SVR4_CRC = (FORMAT_CPIO | 5)
187
- FORMAT_SHAR = 0x20000
188
- FORMAT_SHAR_BASE = (FORMAT_SHAR | 1)
189
- FORMAT_SHAR_DUMP = (FORMAT_SHAR | 2)
190
- FORMAT_TAR = 0x30000
191
- FORMAT_TAR_USTAR = (FORMAT_TAR | 1)
192
- FORMAT_TAR_PAX_INTERCHANGE = (FORMAT_TAR | 2)
193
- FORMAT_TAR_PAX_RESTRICTED = (FORMAT_TAR | 3)
194
- FORMAT_TAR_GNUTAR = (FORMAT_TAR | 4)
195
- FORMAT_ISO9660 = 0x40000
196
- FORMAT_ISO9660_ROCKRIDGE = (FORMAT_ISO9660 | 1)
197
- FORMAT_ZIP = 0x50000
198
- FORMAT_EMPTY = 0x60000
199
- FORMAT_AR = 0x70000
200
- FORMAT_AR_GNU = (FORMAT_AR | 1)
201
- FORMAT_AR_BSD = (FORMAT_AR | 2)
202
- FORMAT_MTREE = 0x80000
203
- FORMAT_RAW = 0x90000
204
- FORMAT_XAR = 0xA0000
180
+ FORMAT_BASE_MASK = 0xff0000
181
+ FORMAT_CPIO = 0x10000
182
+ FORMAT_CPIO_POSIX = (FORMAT_CPIO | 1)
183
+ FORMAT_CPIO_BIN_LE = (FORMAT_CPIO | 2)
184
+ FORMAT_CPIO_BIN_BE = (FORMAT_CPIO | 3)
185
+ FORMAT_CPIO_SVR4_NOCRC = (FORMAT_CPIO | 4)
186
+ FORMAT_CPIO_SVR4_CRC = (FORMAT_CPIO | 5)
187
+ FORMAT_SHAR = 0x20000
188
+ FORMAT_SHAR_BASE = (FORMAT_SHAR | 1)
189
+ FORMAT_SHAR_DUMP = (FORMAT_SHAR | 2)
190
+ FORMAT_TAR = 0x30000
191
+ FORMAT_TAR_USTAR = (FORMAT_TAR | 1)
192
+ FORMAT_TAR_PAX_INTERCHANGE = (FORMAT_TAR | 2)
193
+ FORMAT_TAR_PAX_RESTRICTED = (FORMAT_TAR | 3)
194
+ FORMAT_TAR_GNUTAR = (FORMAT_TAR | 4)
195
+ FORMAT_ISO9660 = 0x40000
196
+ FORMAT_ISO9660_ROCKRIDGE = (FORMAT_ISO9660 | 1)
197
+ FORMAT_ZIP = 0x50000
198
+ FORMAT_EMPTY = 0x60000
199
+ FORMAT_AR = 0x70000
200
+ FORMAT_AR_GNU = (FORMAT_AR | 1)
201
+ FORMAT_AR_BSD = (FORMAT_AR | 2)
202
+ FORMAT_MTREE = 0x80000
203
+ FORMAT_RAW = 0x90000
204
+ FORMAT_XAR = 0xA0000
205
205
 
206
- EXTRACT_OWNER = (0x0001)
207
- EXTRACT_PERM = (0x0002)
208
- EXTRACT_TIME = (0x0004)
209
- EXTRACT_NO_OVERWRITE = (0x0008)
210
- EXTRACT_UNLINK = (0x0010)
211
- EXTRACT_ACL = (0x0020)
212
- EXTRACT_FFLAGS = (0x0040)
213
- EXTRACT_XATTR = (0x0080)
214
- EXTRACT_SECURE_SYMLINKS = (0x0100)
215
- EXTRACT_SECURE_NODOTDOT = (0x0200)
216
- EXTRACT_NO_AUTODIR = (0x0400)
217
- EXTRACT_NO_OVERWRITE_NEWER = (0x0800)
218
- EXTRACT_SPARSE = (0x1000)
206
+ EXTRACT_OWNER = (0x0001)
207
+ EXTRACT_PERM = (0x0002)
208
+ EXTRACT_TIME = (0x0004)
209
+ EXTRACT_NO_OVERWRITE = (0x0008)
210
+ EXTRACT_UNLINK = (0x0010)
211
+ EXTRACT_ACL = (0x0020)
212
+ EXTRACT_FFLAGS = (0x0040)
213
+ EXTRACT_XATTR = (0x0080)
214
+ EXTRACT_SECURE_SYMLINKS = (0x0100)
215
+ EXTRACT_SECURE_NODOTDOT = (0x0200)
216
+ EXTRACT_NO_AUTODIR = (0x0400)
217
+ EXTRACT_NO_OVERWRITE_NEWER = (0x0800)
218
+ EXTRACT_SPARSE = (0x1000)
219
219
 
220
- def self.read_open_filename file_name, command = nil, &block
221
- Reader.open_filename file_name, command, &block
222
- end
220
+ def self.read_open_filename file_name, command = nil, &block
221
+ Reader.open_filename file_name, command, &block
222
+ end
223
223
 
224
- def self.read_open_memory string, command = nil, &block
225
- Reader.open_memory string, command, &block
226
- end
224
+ def self.read_open_memory string, command = nil, &block
225
+ Reader.open_memory string, command, &block
226
+ end
227
227
 
228
- def self.write_open_filename file_name, compression, format, &block
229
- Writer.open_filename file_name, compression, format, &block
230
- end
228
+ def self.write_open_filename file_name, compression, format, &block
229
+ Writer.open_filename file_name, compression, format, &block
230
+ end
231
231
 
232
- def self.write_open_memory string, compression, format, &block
233
- Writer.open_memory string, compression, format, &block
234
- end
232
+ def self.write_open_memory string, compression, format, &block
233
+ Writer.open_memory string, compression, format, &block
234
+ end
235
235
 
236
- def self.version_number
237
- C::archive_version_number
238
- end
236
+ def self.version_number
237
+ C::archive_version_number
238
+ end
239
239
 
240
- def self.version_string
241
- C::archive_version_string
242
- end
240
+ def self.version_string
241
+ C::archive_version_string
242
+ end
243
243
 
244
- class Error < StandardError
245
- def initialize(archive)
246
- if archive.kind_of? String
247
- super archive
248
- else
249
- super "#{C::archive_error_string(archive)}"
250
- end
251
- end
244
+ class Error < StandardError
245
+ def initialize(archive)
246
+ if archive.kind_of? String
247
+ super archive
248
+ else
249
+ super "#{C::archive_error_string(archive)}"
250
+ end
252
251
  end
252
+ end
253
253
 
254
- class BaseArchive
254
+ class BaseArchive
255
255
 
256
- def initialize alloc, free
257
- @archive = nil
258
- @archive_free = nil
259
- @archive = alloc.call
260
- @archive_free = [nil]
261
- raise Error, @archive unless @archive
256
+ def initialize alloc, free
257
+ @archive = nil
258
+ @archive_free = nil
259
+ @archive = alloc.call
260
+ @archive_free = [nil]
261
+ raise Error, @archive unless @archive
262
262
 
263
- @archive_free[0] = free
264
- ObjectSpace.define_finalizer( self, BaseArchive.finalizer(@archive, @archive_free) )
265
- end
263
+ @archive_free[0] = free
264
+ ObjectSpace.define_finalizer( self, BaseArchive.finalizer(@archive, @archive_free) )
265
+ end
266
266
 
267
- def self.finalizer archive, archive_free
268
- Proc.new do |*args|
269
- archive_free[0].call(archive) if archive_free[0]
270
- end
271
- end
267
+ def self.finalizer archive, archive_free
268
+ Proc.new do |*args|
269
+ archive_free[0].call(archive) if archive_free[0]
270
+ end
271
+ end
272
272
 
273
- def close
274
- # TODO: do we need synchronization here?
275
- if @archive
276
- # TODO: Error check?
277
- @archive_free[0].call(@archive)
278
- end
279
- ensure
280
- @archive = nil
281
- @archive_free[0] = nil
282
- @data = nil
283
- end
273
+ def close
274
+ # TODO: do we need synchronization here?
275
+ if @archive
276
+ # TODO: Error check?
277
+ @archive_free[0].call(@archive)
278
+ end
279
+ ensure
280
+ @archive = nil
281
+ @archive_free[0] = nil
282
+ @data = nil
283
+ end
284
284
 
285
- def archive
286
- raise Error, "No archive open" unless @archive
287
- @archive
288
- end
289
- protected :archive
285
+ def archive
286
+ raise Error, "No archive open" unless @archive
287
+ @archive
288
+ end
289
+ protected :archive
290
290
 
291
- def error_string
292
- C::archive_error_string(@archive)
293
- end
291
+ def error_string
292
+ C::archive_error_string(@archive)
293
+ end
294
294
 
295
- def errno
296
- C::archive_errno(@archive)
297
- end
295
+ def errno
296
+ C::archive_errno(@archive)
298
297
  end
298
+ end
299
299
 
300
300
  end