Gsf.Input

g GObject.Object GObject.Object Gsf.Input Gsf.Input GObject.Object->Gsf.Input

Subclasses:

Gsf.Infile, Gsf.InputGZip, Gsf.InputGio, Gsf.InputHTTP, Gsf.InputMemory, Gsf.InputProxy, Gsf.InputStdio, Gsf.InputTextline

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

error_id ()

class

mmap_new (filename)

container ()

copy (output)

dump (dump_as_hex)

dup ()

eof ()

find_vba ()

get_modtime ()

name ()

read (num_bytes)

remaining ()

seek (offset, whence)

seek_emulate (pos)

set_container (container)

set_modtime (modtime)

set_modtime_from_stat (st)

set_name (name)

set_name_from_filename (filename)

set_size (size)

sibling (name)

size ()

tell ()

uncompress ()

Virtual Methods

Inherited:

GObject.Object (7)

do_Dup ()

do_OpenSibling (name)

do_Seek (offset, whence)

Properties

Name

Type

Flags

Short Description

container

Gsf.Infile

r

The parent Gsf.Infile

eof

bool

r

End of file

modtime

GLib.DateTime

r

An optional GLib.DateTime representing the time the input was last changed

name

str

r

The input’s name

position

int

r

The input’s current position

remaining

int

r

Amount of data remaining

size

int

r

The input’s size

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

cur_offset

int

r

g_object

GObject.Object

r

Class Details

class Gsf.Input(**kwargs)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gsf.InputClass

Class representing an input stream.

classmethod error_id()
Returns:

A utility quark to flag a GLib.Error as being an input problem.

Return type:

int

classmethod mmap_new(filename)
Parameters:

filename (str) – The file on disk that you want to mmap

Raises:

GLib.Error

Returns:

A new Gsf.InputMemory

Return type:

Gsf.Input

container()
Returns:

self's container

Return type:

Gsf.Infile or None

copy(output)
Parameters:

output (Gsf.Output) – a non-null Gsf.Output

Returns:

True on success

Return type:

bool

Copy the contents from self 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, GLib.SeekType.SET) and Gsf.Output.seek (output, 0, GLib.SeekType.SET) first, if applicable.

dump(dump_as_hex)
Parameters:

dump_as_hex (bool) – If True, dump in hexidecmal format

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

dup()
Raises:

GLib.Error

Returns:

the duplicate

Return type:

Gsf.Input or None

Duplicates self leaving the new one at the same offset.

eof()
Returns:

True if the input is at the eof.

Return type:

bool

Are we at the end of the file?

find_vba()
Raises:

GLib.Error

Returns:

a Gsf.Infile

Return type:

Gsf.InfileMSVBA or None

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

get_modtime()
Returns:

A GLib.DateTime representing when the input was last modified, or None if not known.

Return type:

GLib.DateTime

name()
Returns:

self's name in utf8 form, or None if it has no name.

Return type:

str

The name of the input stream.

read(num_bytes)
Parameters:

num_bytes (int) – number of bytes to read

Returns:

the data read.

Return type:

bytes

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

remaining()
Returns:

the number of bytes left in the file.

Return type:

int

seek(offset, whence)
Parameters:
  • offset (int) – 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:

True on error.

Return type:

bool

Move the current location in the input stream.

seek_emulate(pos)
Parameters:

pos (int) – absolute position to seek to

Returns:

True if the emulation failed.

Return type:

bool

Emulate forward seeks by reading.

set_container(container)
Parameters:

container (Gsf.Infile or None) –

Returns:

True if the assignment was ok.

Return type:

bool

set_modtime(modtime)
Parameters:

modtime (GLib.DateTime or None) – the new modification time.

Returns:

True if the assignment was ok.

Return type:

bool

protected.

set_modtime_from_stat(st)
Parameters:

st (object or None) –

Return type:

bool

set_name(name)
Parameters:

name (str or None) – the new name of the stream

Returns:

True if the assignment was ok.

Return type:

bool

protected.

set_name_from_filename(filename)
Parameters:

filename (str) – the (fs-sys encoded) filename

Returns:

True if the assignment was ok.

Return type:

bool

protected.

set_size(size)
Parameters:

size (int) – the size of the stream

Returns:

True if the assignment was ok.

Return type:

bool

sibling(name)
Parameters:

name (str) – name.

Raises:

GLib.Error

Returns:

A related Gsf.Input

Return type:

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 self. The caller is responsible for managing the resulting object.

size()
Returns:

the total number of bytes in the input or -1 on error

Return type:

int

tell()
Returns:

the current offset in the file.

Return type:

int

uncompress()
Returns:

A stream equivalent to the source stream, but uncompressed if the source was compressed.

Return type:

Gsf.Input

This functions takes ownership of the incoming reference and yields a new one as its output.

do_Dup() virtual
Returns:

the duplicate

Return type:

Gsf.Input or None

Duplicates input leaving the new one at the same offset.

do_OpenSibling(name) virtual
Parameters:

name (str) – name.

Returns:

A related Gsf.Input

Return type:

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.

do_Seek(offset, whence) virtual
Parameters:
  • offset (int) – 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:

True on error.

Return type:

bool

Move the current location in the input stream.

Property Details

Gsf.Input.props.container
Name:

container

Type:

Gsf.Infile

Default Value:

None

Flags:

READABLE

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

Gsf.Input.props.eof
Name:

eof

Type:

bool

Default Value:

False

Flags:

READABLE

True if the end of the file has been reached.

Gsf.Input.props.modtime
Name:

modtime

Type:

GLib.DateTime

Default Value:

None

Flags:

READABLE

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.

Gsf.Input.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE

The input’s name

Gsf.Input.props.position
Name:

position

Type:

int

Default Value:

0

Flags:

READABLE

The current position in the input.

Gsf.Input.props.remaining
Name:

remaining

Type:

int

Default Value:

0

Flags:

READABLE

The number of bytes remaining in the file.

Gsf.Input.props.size
Name:

size

Type:

int

Default Value:

0

Flags:

READABLE

The total number of bytes in the file.