gnomevfs.Handle
Prev | The gnomevfs class reference | Next

## gnomevfs.Handle

gnomevfs.Handle — Object representing an open file

## Synopsis

    class gnomevfs.Handle:
        gnomevfs.Handle(uri, open_mode=gnomevfs.OPEN_READ)
        def close()
        def get_file_info(options=gnomevfs.FILE_INFO_DEFAULT)
        def read(bytes)
        def seek(offset, whence=gnomevfs.SEEK_START)
        def tell()
        def truncate(length)
        def write(buffer)

## Description

## Constructor

                gnomevfs.Handle(uri, open_mode=gnomevfs.OPEN_READ)

`uri`: | The URI to open.
`open_mode`: | Or'd set of open mode flags
Returns: | the new `gnomevfs.Handle`

## Methods

### gnomevfs.Handle.close

                def close()

Close the file associated with this handle.

### gnomevfs.Handle.get_file_info

                def get_file_info(options=gnomevfs.FILE_INFO_DEFAULT)

`options`: | Or'd set of file info options
Returns: | A gnomevfs.FileInfo.

Get information about the file, persuant to the options given.

### gnomevfs.Handle.read

                def read(bytes)

`bytes`: | The number of bytes to read
Returns: | A string containing the data.

Read `bytes` from file. The actual number of bytes read may be less than this, so you may need to check the length of the string returned.

### gnomevfs.Handle.seek

                def seek(offset, whence=gnomevfs.SEEK_START)

`offset`: | The number of bytes to offset from the position specified by `whence`. This can be either positive or negative.
`whence`: | The start position.

Set the current position for reading/writing.

### gnomevfs.Handle.tell

                def tell()

Returns: | A long specifying the current byte position.

Returns the current position in the file. This is the position at which any reads or writes will begin at.

### gnomevfs.Handle.truncate

                def truncate(length)

`length`: | The length to truncate to.

Truncates the file to the length specified.

### gnomevfs.Handle.write

                def write(buffer)

`buffer`: | The buffer to write to the file.
Returns: | The number of bytes written.

Write `buffer` to the file. The number of bytes actually written may be less than the buffer, as is provided as the return value.

Prev | Up | Next
gnomevfs.FileInfo | Home | gnomevfs.URI