class Archive::Entry

Constants

BLOCK_SPECIAL
CHARACTER_SPECIAL
DIRECTORY
FIFO
FILE
SOCKET
S_IFBLK
S_IFCHR
S_IFDIR
S_IFIFO
S_IFLNK
S_IFMT
S_IFREG
S_IFSOCK

Public Class Methods

finalizer(entry, entry_free) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 45
def self.finalizer(entry, entry_free)
  proc do |*_args|
    C.archive_entry_free(entry) unless entry_free[0]
  end
end
from_pointer(entry, clone: false) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 20
def self.from_pointer(entry, clone: false)
  new entry, clone: clone
end
new(entry = nil, clone: false) { |self| ... } click to toggle source
# File lib/ffi-libarchive/entry.rb, line 24
def initialize(entry = nil, clone: false)
  @entry_free = [true]
  if entry
    @entry = clone ? C.archive_entry_clone(entry) : entry
    yield self if block_given?
  else
    @entry = C.archive_entry_new
    raise Error, @entry unless @entry

    if block_given?
      result = yield self
      C.archive_entry_free(@entry)
      @entry = nil
      result
    else
      @entry_free[0] = false
      ObjectSpace.define_finalizer(self, Entry.finalizer(@entry, @entry_free))
    end
  end
end

Public Instance Methods

atime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 67
def atime
  Time.at C.archive_entry_atime(entry)
end
atime=(time) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 71
def atime=(time)
  set_atime time, 0
end
atime_is_set?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 79
def atime_is_set?
  C.archive_entry_atime_is_set(entry) != 0
end
atime_nsec() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 83
def atime_nsec
  C.archive_entry_atime_nsec(entry)
end
birthtime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 87
def birthtime
  Time.at C.archive_entry_birthtime(entry)
end
birthtime=(time) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 91
def birthtime=(time)
  set_birthtime time, 0
end
birthtime_is_set?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 99
def birthtime_is_set?
  C.archive_entry_birthtime_is_set(entry) != 0
end
birthtime_nsec() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 103
def birthtime_nsec
  C.archive_entry_birthtime_nsec(entry)
end
block_special?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 127
def block_special?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFBLK
end
character_special?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 131
def character_special?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFCHR
end
close() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 51
def close
  # TODO: do we need synchronization here?
  if @entry && !@entry_free[0]
    @entry_free[0] = true
    C.archive_entry_free(@entry)
  end
ensure
  @entry = nil
end
copy_fflags_text(fflags_text) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 156
def copy_fflags_text(fflags_text)
  C.archive_entry_copy_fflags_text(entry, fflags_text)
  nil
end
copy_gname(gname) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 161
def copy_gname(gname)
  C.archive_entry_copy_gname(entry, gname)
  nil
end
copy_lstat(filename) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 176
def copy_lstat(filename)
  # TODO: get this work without ffi-inliner
  begin
    require File.join(Archive::LIBPATH, "ffi-libarchive", "stat")
  rescue => e
    raise "ffi-inliner build for copy_stat failed:\n#{e}"
  end

  stat = Archive::Stat.ffi_libarchive_create_lstat(filename)
  raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?

  C.archive_entry_copy_stat(entry, stat)
ensure
  Archive::Stat.ffi_libarchive_free_stat(stat)
end
copy_pathname(file_name) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 192
def copy_pathname(file_name)
  C.archive_entry_copy_pathname(entry, file_name)
  nil
end
copy_sourcepath(path) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 197
def copy_sourcepath(path)
  C.archive_copy_sourcepath(entry, path)
  nil
end
copy_stat(filename) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 202
def copy_stat(filename)
  # TODO: get this work without ffi-inliner
  begin
    require File.join(Archive::LIBPATH, "ffi-libarchive", "stat")
  rescue => e
    raise "ffi-inliner build for copy_stat failed:\n#{e}"
  end

  stat = Archive::Stat.ffi_libarchive_create_stat(filename)
  raise Error, "Copy stat failed: #{Archive::Stat.ffi_error}" if stat.null?

  C.archive_entry_copy_stat(entry, stat)
ensure
  Archive::Stat.ffi_libarchive_free_stat(stat)
end
copy_uname(uname) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 223
def copy_uname(uname)
  C.archive_copy_uname(entry, uname)
  nil
end
ctime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 107
def ctime
  Time.at C.archive_entry_ctime(entry)
end
ctime=(time) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 111
def ctime=(time)
  set_ctime time, 0
end
ctime_is_set?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 119
def ctime_is_set?
  C.archive_entry_ctime_is_set(entry) != 0
end
ctime_nsec() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 123
def ctime_nsec
  C.archive_entry_ctime_nsec(entry)
end
dev() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 228
def dev
  C.archive_entry_dev(entry)
end
dev=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 232
def dev=(dev)
  C.archive_entry_set_dev(entry, dev)
end
devmajor() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 236
def devmajor
  C.archive_entry_devmajor(entry)
end
devmajor=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 240
def devmajor=(dev)
  C.archive_entry_set_devmajor(entry, dev)
end
devminor() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 244
def devminor
  C.archive_entry_devminor(entry)
end
devminor=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 248
def devminor=(dev)
  C.archive_entry_set_devminor(entry, dev)
end
directory?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 135
def directory?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFDIR
end
entry() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 61
def entry
  raise "No entry object" unless @entry

  @entry
end
fflags() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 252
def fflags
  set = FFI::MemoryPointer.new :long
  clear = FFI::MemoryPointer.new :long
  C.archive_entry_fflags(entry, set, clear)
  [set.get_long(0), clear.get_long(0)]
end
fflags_text() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 259
def fflags_text
  C.archive_entry_fflags_text(entry)
end
fifo?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 139
def fifo?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFIFO
end
file?()
Alias for: regular?
filetype() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 263
def filetype
  C.archive_entry_filetype(entry)
end
filetype=(type) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 267
def filetype=(type)
  type = Entry.const_get type.to_s.upcase.to_sym if type.is_a? Symbol
  C.archive_entry_set_filetype(entry, type)
end
gid() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 272
def gid
  C.archive_entry_gid(entry)
end
gid=(gid) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 276
def gid=(gid)
  C.archive_entry_set_gid(entry, gid)
end
gname() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 280
def gname
  C.archive_entry_gname(entry)
end
gname=(gname) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 284
def gname=(gname)
  C.archive_entry_set_gname(entry, gname)
end
ino() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 296
def ino
  C.archive_entry_ino(entry)
end
ino=(ino) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 300
def ino=(ino)
  C.archive_entry_set_ino(entry, ino)
end
mode() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 308
def mode
  C.archive_entry_mode(entry)
end
mode=(mode) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 312
def mode=(mode)
  C.archive_entry_set_mode(entry, mode)
end
mtime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 316
def mtime
  Time.at C.archive_entry_mtime(entry)
end
mtime=(time) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 320
def mtime=(time)
  set_mtime time, 0
end
mtime_is_set?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 328
def mtime_is_set?
  C.archive_entry_mtime_is_set(entry) != 0
end
mtime_nsec() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 332
def mtime_nsec
  C.archive_entry_mtime_nsec(entry)
end
pathname() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 344
def pathname
  C.archive_entry_pathname(entry)
end
pathname=(path) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 348
def pathname=(path)
  C.archive_entry_set_pathname(entry, path)
end
perm=(perm) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 352
def perm=(perm)
  C.archive_entry_set_perm(entry, perm)
end
rdev() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 356
def rdev
  C.archive_entry_rdev(entry)
end
rdev=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 360
def rdev=(dev)
  C.archive_entry_set_rdev(entry, dev)
end
rdevmajor() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 364
def rdevmajor
  C.archive_entry_rdevmajor(entry)
end
rdevmajor=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 368
def rdevmajor=(dev)
  C.archive_entry_set_rdevmajor(entry, dev)
end
rdevminor() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 372
def rdevminor
  C.archive_entry_rdevminor(entry)
end
rdevminor=(dev) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 376
def rdevminor=(dev)
  C.archive_entry_set_rdevminor(entry, dev)
end
regular?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 143
def regular?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFREG
end
Also aliased as: file?
set_atime(time, nsec) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 75
def set_atime(time, nsec)
  C.archive_entry_set_atime(entry, time.to_i, nsec)
end
set_birthtime(time, nsec) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 95
def set_birthtime(time, nsec)
  C.archive_entry_set_birthtime(entry, time.to_i, nsec)
end
set_ctime(time, nsec) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 115
def set_ctime(time, nsec)
  C.archive_entry_set_ctime(entry, time.to_i, nsec)
end
set_fflags(set, clear) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 380
def set_fflags(set, clear)
  C.archive_entry_set_fflags(entry, set, clear)
end
set_mtime(time, nsec) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 324
def set_mtime(time, nsec)
  C.archive_entry_set_mtime(entry, time.to_i, nsec)
end
size() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 384
def size
  C.archive_entry_size(entry)
end
size=(size) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 388
def size=(size)
  C.archive_entry_set_size(entry, size)
end
size_is_set?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 392
def size_is_set?
  C.archive_entry_size_is_set(entry) != 0
end
socket?() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 148
def socket?
  C.archive_entry_filetype(entry) & S_IFMT == S_IFSOCK
end
sourcepath() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 396
def sourcepath
  C.archive_entry_sourcepath(entry)
end
strmode() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 400
def strmode
  C.archive_entry_strmode(entry)
end
uid() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 412
def uid
  C.archive_entry_uid(entry)
end
uid=(uid) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 416
def uid=(uid)
  C.archive_entry_set_uid(entry, uid)
end
uname() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 420
def uname
  C.archive_entry_uname(entry)
end
uname=(uname) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 424
def uname=(uname)
  C.archive_entry_set_uname(entry, uname)
end
unset_atime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 428
def unset_atime
  C.archive_entry_unset_atime(entry)
end
unset_birthtime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 432
def unset_birthtime
  C.archive_entry_unset_birthtime(entry)
end
unset_ctime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 436
def unset_ctime
  C.archive_entry_unset_ctime(entry)
end
unset_mtime() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 440
def unset_mtime
  C.archive_entry_unset_mtime(entry)
end
unset_size() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 444
def unset_size
  C.archive_entry_unset_size(entry)
end
xattr_add_entry(name, value) click to toggle source
# File lib/ffi-libarchive/entry.rb, line 448
def xattr_add_entry(name, value)
  C.archive_entry_xattr_add_entry(entry, name, value, value.size)
end
xattr_clear() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 452
def xattr_clear
  C.archive_entry_xattr_clear(entry)
end
xattr_count() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 456
def xattr_count
  C.archive_entry_xattr_count(entry)
end
xattr_next() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 460
def xattr_next
  name = FFI::MemoryPointer.new :pointer
  value = FFI::MemoryPointer.new :pointer
  size = FFI::MemoryPointer.new :size_t
  if C.archive_entry_xattr_next(entry, name, value, size) != C::OK
    nil
  else
    # TODO: someday size.read_size_t could work
    [name.null? ? nil : name.read_string,
            value.null? ? nil : value.get_string(0, size.read_ulong)]
  end
end
xattr_reset() click to toggle source
# File lib/ffi-libarchive/entry.rb, line 473
def xattr_reset
  C.archive_entry_xattr_reset(entry)
end