File Operations
3
GNOME-VFS-2.0 Library

# File Operations

basic POSIX-style file operations

## Synopsis

    typedef             GnomeVFSMethodHandle;
    typedef             GnomeVFSHandle;

## Description

## Details

### GnomeVFSMethodHandle

    typedef gpointer GnomeVFSMethodHandle;

Generic handle (pointer) that encapsulates the method internals associated with a specific resource.

Methods are supposed to store all information and open resources regarding a handle in a dynamically allocated structure, which is casted into a GnomeVFSMethodHandle (in fact a void pointer) when it is passed around in generic GnomeVFS functions. During the lifetime of a handle, GnomeVFS stores it as a generic pointer. After closing a handle, it will not be known to GnomeVFS anymore.

There are file handles and file monitor handles.

File handles are opened in the GnomeVFSMethod's GnomeVFSMethodOpenFunc, GnomeVFSMethodCreateFunc and GnomeVFSMethodOpenDirectoryFunc and closed in its GnomeVFSMethodCloseFunc and GnomeVFSMethodCloseDirectoryFunc.

A number of GnomeVFSMethod operations rely on file handles:

GnomeVFSMethodReadFunc GnomeVFSMethodWriteFunc GnomeVFSMethodSeekFunc GnomeVFSMethodTellFunc GnomeVFSMethodGetFileInfoFromHandleFunc GnomeVFSMethodTruncateHandleFunc GnomeVFSMethodFileControlFunc

File monitor handles however are created using GnomeVFSMethodMonitorAddFunc and cancelled using GnomeVFSMethodMonitorCancelFunc

### GnomeVFSHandle

    typedef struct GnomeVFSHandle GnomeVFSHandle;

Handle to a file.

A handle is obtained using `gnome_vfs_open()` and `gnome_vfs_create()` family of functions on the file. A handle represents a file stream, `gnome_vfs_close()`, `gnome_vfs_write()`, `gnome_vfs_read()` and all the other I/O operations take a GnomeVFSHandle * that identifies the file where the operation is going to be performed.