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
- #compression ⇒ Object
- #compression_name ⇒ Object
- #errno ⇒ Object
- #error_string ⇒ Object
- #format ⇒ Object
- #format_name ⇒ Object
-
#initialize(alloc, free) ⇒ BaseArchive
constructor
A new instance of BaseArchive.
Constructor Details
#initialize(alloc, free) ⇒ BaseArchive
Returns a new instance of BaseArchive.
332 333 334 335 336 337 338 339 340 341 |
# File 'lib/ffi-libarchive/archive.rb', line 332 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
343 344 345 346 347 |
# File 'lib/ffi-libarchive/archive.rb', line 343 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
349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/ffi-libarchive/archive.rb', line 349 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 |
#compression ⇒ Object
368 369 370 |
# File 'lib/ffi-libarchive/archive.rb', line 368 def compression C.archive_compression(@archive) end |
#compression_name ⇒ Object
372 373 374 |
# File 'lib/ffi-libarchive/archive.rb', line 372 def compression_name C.archive_compression_name(@archive) end |
#errno ⇒ Object
380 381 382 |
# File 'lib/ffi-libarchive/archive.rb', line 380 def errno C.archive_errno(@archive) end |
#error_string ⇒ Object
376 377 378 |
# File 'lib/ffi-libarchive/archive.rb', line 376 def error_string C.archive_error_string(@archive) end |
#format ⇒ Object
384 385 386 |
# File 'lib/ffi-libarchive/archive.rb', line 384 def format C.archive_format(@archive) end |
#format_name ⇒ Object
388 389 390 |
# File 'lib/ffi-libarchive/archive.rb', line 388 def format_name C.archive_format_name(@archive) end |