class Rupert::RPM::Entry

Attributes

tag[RW]

Public Class Methods

new(tag, type, offset, count) click to toggle source

Initializes a new index entry.

@param tag [String] 4 byte entry tag (semantic data type) @param type [String] 4 byte entry data format @param offset [String] 4 byte pointer to data in the index store @param count [String] 4 byte number of data items held by the entry

# File lib/rupert/rpm/entry.rb, line 10
def initialize(tag, type, offset, count)
  @tag, @type, @offset, @count = tag, type, offset, count
end

Public Instance Methods

resolve(store) click to toggle source

Fetches referenced data from a store.

An entry contains only information about a piece of data, but not the actual data. In essence, it behaves more or less like a pointer, which contains the address at which data is available.

This method behaves exactly like pointer dereference, i.e. it returns the actual data at the address held by the entry itself. In addition, data is not returned in raw form; instead, it is returned in the format declared in the entry itself. The available RPM formats are the following:

  • NULL

  • CHAR

  • INT8

  • INT16

  • INT32

  • INT64 (not supported yet even in rpmlib?)

  • STRING

  • BIN

  • STRING_ARRAY

  • I18NSTRING

which are in turn mapped in Ruby with:

  • nil

  • (Array of) String of length 1

  • (Array of) Fixnum

  • (Array of) Fixnum

  • (Array of) Fixnum

  • (Array of) Fixnum/Bignum

  • String of arbitrary length

  • String of arbitrary length, 8-bit ASCII encoded

  • Array of String

  • Array of String

NOTE: The store is sought to retrieve data. Do not make any assumptions on IO’s pointer state after method call. If you need to perform subsequent operations on the IO that require a particular cursor position, seek the IO to wanted position before performing the operation.

@param store [IO] raw data store, represented by an IO object @return [Object] data referenced by this entry, in whatever format

the entry prescribe
# File lib/rupert/rpm/entry.rb, line 61
def resolve(store)
  store.seek(@offset, IO::SEEK_SET)
  read_and_convert(@type, store)
end