Class: Archive::BaseArchive
- Inherits:
-
Object
- Object
- Archive::BaseArchive
- Defined in:
- lib/ffi-libarchive/archive.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #errno ⇒ Object
- #error_string ⇒ Object
-
#initialize(alloc, free) ⇒ BaseArchive
constructor
A new instance of BaseArchive.
Constructor Details
#initialize(alloc, free) ⇒ BaseArchive
Returns a new instance of BaseArchive.
322 323 324 325 326 327 328 329 330 331 |
# File 'lib/ffi-libarchive/archive.rb', line 322 def initialize(alloc, free) @archive = nil @archive_free = nil @archive = alloc.call @archive_free = [nil] raise Error, @archive unless @archive @archive_free[0] = free ObjectSpace.define_finalizer(self, BaseArchive.finalizer(@archive, @archive_free)) end |
Class Method Details
.finalizer(archive, archive_free) ⇒ Object
333 334 335 336 337 |
# File 'lib/ffi-libarchive/archive.rb', line 333 def self.finalizer(archive, archive_free) proc do |*_args| archive_free[0].call(archive) if archive_free[0] end end |
Instance Method Details
#close ⇒ Object
339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/ffi-libarchive/archive.rb', line 339 def close # TODO: do we need synchronization here? if @archive # TODO: Error check? @archive_free[0].call(@archive) end ensure @archive = nil @archive_free[0] = nil @data = nil end |
#errno ⇒ Object
362 363 364 |
# File 'lib/ffi-libarchive/archive.rb', line 362 def errno C.archive_errno(@archive) end |
#error_string ⇒ Object
358 359 360 |
# File 'lib/ffi-libarchive/archive.rb', line 358 def error_string C.archive_error_string(@archive) end |