Class: Gsf::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/gsf/input.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Gsf::Input

Returns A new Gsf::InputMemory.

Parameters:

  • filename (String)

    The file on disk that you want to mmap

Class Method Details

.error_idGLib::Quark

Returns A utility quark to flag a #GError as being an input problem.

Returns:

  • (GLib::Quark)

    A utility quark to flag a #GError as being an input problem.

Instance Method Details

#containerGsf::Infile

The container, optionally nil, in which this input lives.

Returns:

#container=(container) ⇒ Gsf::Infile

The container, optionally nil, in which this input lives.

Parameters:

Returns:

#copy(output) ⇒ Boolean

Copy the contents from input to output from their respective current positions. So if you want to be sure to copy everything, make sure to call gsf_input_seek (input, 0, G_SEEK_SET) and gsf_output_seek (output, 0, G_SEEK_SET) first, if applicable.

Parameters:

Returns:

  • (Boolean)

    true on success

#dump(dump_as_hex) ⇒ nil

Dumps input's contents to STDOUT, optionally in hex format.

Parameters:

  • dump_as_hex (Boolean)

    If true, dump in hexidecmal format

Returns:

  • (nil)

#dupGsf::Input

Duplicates input leaving the new one at the same offset.

Returns:

#eofBoolean

Are we at the end of the file?

Returns:

  • (Boolean)

    true if the input is at the eof.

#eof=(eof) ⇒ Boolean

true if the end of the file has been reached.

Parameters:

  • eof (Boolean)

Returns:

  • (Boolean)

    eof

  • (Boolean)

    eof

#eof?Boolean

true if the end of the file has been reached.

Returns:

  • (Boolean)

    eof

#find_vbaGsf::InfileMSVBA

A utility routine that attempts to find the VBA file withint a stream.

Returns:

#modtimeGLib::DateTime

The time the input was last updated. This represents the timestamp from the originating file or GsfInfile member. It is not supported by all derived classes.

Returns:

  • (GLib::DateTime)

    modtime

#modtime=(modtime) ⇒ GLib::DateTime

The time the input was last updated. This represents the timestamp from the originating file or GsfInfile member. It is not supported by all derived classes.

Parameters:

  • modtime (GLib::DateTime)

Returns:

  • (GLib::DateTime)

    modtime

  • (GLib::DateTime)

    modtime

#modtime_from_stat=(st) ⇒ Boolean

Parameters:

  • st (GObject)

Returns:

  • (Boolean)

#nameString

Returns name.

Returns:

  • (String)

    name

#name=(name) ⇒ String

Parameters:

  • name (String)

Returns:

  • (String)

    name

  • (String)

    name

#name_from_filename=(filename) ⇒ Boolean

protected.

Parameters:

  • filename (String)

    the (fs-sys encoded) filename

Returns:

  • (Boolean)

    true if the assignment was ok.

#positionInteger

The current position in the input.

Returns:

  • (Integer)

    position

#position=(position) ⇒ Integer

The current position in the input.

Parameters:

  • position (Integer)

Returns:

  • (Integer)

    position

  • (Integer)

    position

#read(size = nil) ⇒ Array<Integer>

Read at least num_bytes. Does not change the current position if there is an error. Will only read if the entire amount can be read. Invalidates the buffer associated with previous calls to gsf_input_read. an error or 0 bytes are requested.

Parameters:

  • num_bytes (Integer)

    number of bytes to read

  • optional_buffer (Array<Integer>)

    Pointer to destination memory area

Returns:

  • (Array<Integer>)

    pointer to the buffer or nil if there is



20
21
22
23
24
# File 'lib/gsf/input.rb', line 20

def read(size=nil)
  size ||= remaining
  bytes = read_raw(size)
  bytes.pack("C*")
end

#read0(num_bytes, bytes_read) ⇒ Array<Integer>

Read num_bytes. Does not change the current position if there is an error. Will only read if the entire amount can be read. the data read.

Parameters:

  • num_bytes (Integer)

    number of bytes to read

  • bytes_read (Integer)

    copy of num_bytes

Returns:

  • (Array<Integer>)

#read_rawArray<Integer>

Read at least num_bytes. Does not change the current position if there is an error. Will only read if the entire amount can be read. Invalidates the buffer associated with previous calls to gsf_input_read. an error or 0 bytes are requested.

Parameters:

  • num_bytes (Integer)

    number of bytes to read

  • optional_buffer (Array<Integer>)

    Pointer to destination memory area

Returns:

  • (Array<Integer>)

    pointer to the buffer or nil if there is



# File 'lib/gsf/input.rb', line 19

#remainingInteger

The number of bytes remaining in the file.

Returns:

  • (Integer)

    remaining

#remaining=(remaining) ⇒ Integer

The number of bytes remaining in the file.

Parameters:

  • remaining (Integer)

Returns:

  • (Integer)

    remaining

  • (Integer)

    remaining

#seek(offset, whence) ⇒ Boolean

Move the current location in the input stream.

Parameters:

  • offset (Gsf::gsf_off_t)

    target offset

  • whence (GLib::SeekType)

    determines whether the offset is relative to the beginning or the end of the stream, or to the current location.

Returns:

  • (Boolean)

    true on error.

#seek_emulate(pos) ⇒ Boolean

Emulate forward seeks by reading.

Parameters:

  • pos (Gsf::gsf_off_t)

    absolute position to seek to

Returns:

  • (Boolean)

    true if the emulation failed.

#sibling(name) ⇒ Gsf::Input

UNIMPLEMENTED BY ANY BACKEND and it is probably unnecessary. gsf_input_get_container provides enough power to do what is necessary.

Attempts to open a 'sibling' of input. The caller is responsible for managing the resulting object.

Parameters:

  • name (String)

    name.

Returns:

#sizeInteger

The total number of bytes in the file.

Returns:

  • (Integer)

    size

#size=(size) ⇒ Integer

The total number of bytes in the file.

Parameters:

  • size (Integer)

Returns:

  • (Integer)

    size

  • (Integer)

    size

#tellGsf::gsf_off_t

Returns the current offset in the file.

Returns:

  • (Gsf::gsf_off_t)

    the current offset in the file.

#uncompressGsf::Input

This functions takes ownership of the incoming reference and yields a new one as its output. but uncompressed if the source was compressed.

Returns:

  • (Gsf::Input)

    A stream equivalent to the source stream,