![]() |
![]() |
![]() |
[Insert name here] Reference Manual | ![]() |
---|---|---|---|---|
VFSFile; VFSConstructor; VFSFile* vfs_fopen (constgchar *path, constgchar *mode);gint vfs_fclose (VFSFile *file); VFSFile* vfs_dup (VFSFile *in);size_t vfs_fread (gpointer ptr,size_t size,size_t nmemb, VFSFile *file);size_t vfs_fwrite (gconstpointer ptr,size_t size,size_t nmemb, VFSFile *file);gint vfs_getc (VFSFile *stream);gint vfs_ungetc (gint c, VFSFile *stream);gchar * vfs_fgets (gchar *s,gint n, VFSFile *stream);gint vfs_fseek (VFSFile *file,glong offset,gint whence);void vfs_rewind (VFSFile *file);glong vfs_ftell (VFSFile *file);gboolean vfs_feof (VFSFile *file);gboolean vfs_file_test (constgchar *path,GFileTest test);gboolean vfs_is_writeable (constgchar *path);gboolean vfs_truncate (VFSFile *file,glong length);gchar * vfs_get_metadata (VFSFile *file, constgchar *field);int vfs_fprintf (VFSFile *stream,gchar const *format, ...);gboolean vfs_register_transport (VFSConstructor *vtable);void vfs_file_get_contents (constgchar *filename,gchar **buf,gsize *size);
typedef struct { gchar *uri; gpointer handle; VFSConstructor *base; gint ref; } VFSFile;
VFSFile objects describe a VFS stream.
|
The URI of the stream. |
|
Opaque data used by the transport plugins. |
VFSConstructor * |
The base vtable used for VFS functions. |
|
The amount of references that the VFSFile object has. |
typedef struct { gchar *uri_id; VFSFile *(*vfs_fopen_impl)(const gchar *path, const gchar *mode); gint (*vfs_fclose_impl)(VFSFile * file); size_t (*vfs_fread_impl)(gpointer ptr, size_t size, size_t nmemb, VFSFile *file); size_t (*vfs_fwrite_impl)(gconstpointer ptr, size_t size, size_t nmemb, VFSFile *file); gint (*vfs_getc_impl)(VFSFile *stream); gint (*vfs_ungetc_impl)(gint c, VFSFile *stream); gint (*vfs_fseek_impl)(VFSFile *file, glong offset, gint whence); void (*vfs_rewind_impl)(VFSFile *file); glong (*vfs_ftell_impl)(VFSFile *file); gboolean (*vfs_feof_impl)(VFSFile *file); gboolean (*vfs_truncate_impl)(VFSFile *file, glong length); gchar *(*vfs_get_metadata_impl)(VFSFile *file, const gchar * field); } VFSConstructor;
VFSConstructor objects contain the base vtables used for extrapolating
a VFS stream. VFSConstructor objects should be considered virtual
vfs_register_transport()
.
|
The uri identifier, e.g. "file" would handle "file://" streams. |
|
A function pointer which points to a fopen implementation. |
|
A function pointer which points to a fclose implementation. |
|
A function pointer which points to a fread implementation. |
|
A function pointer which points to a fwrite implementation. |
|
A function pointer which points to a getc implementation. |
|
A function pointer which points to an ungetc implementation. |
|
A function pointer which points to a fseek implementation. |
|
A function pointer which points to a rewind implementation. |
|
A function pointer which points to a ftell implementation. |
|
A function pointer which points to a feof implementation. |
|
A function pointer which points to a ftruncate implementation. |
|
VFSFile* vfs_fopen (constgchar *path, constgchar *mode);
Opens a stream from a VFS transport using a VFSConstructor.
|
The path or URI to open. |
|
The preferred access privileges (not guaranteed). |
Returns : |
On success, a VFSFile object representing the stream. |
gint vfs_fclose (VFSFile *file);
Closes a VFS stream and destroys a VFSFile object.
|
A VFSFile object to destroy. |
Returns : |
-1 on failure, 0 on success. |
VFSFile* vfs_dup (VFSFile *in);
Increments the amount of references that are using this FD. References are removed by calling vfs_fclose on the handle returned from this function. If the amount of references reaches zero, then the file will be closed.
|
The VFSFile handle to mark as duplicated. |
Returns : |
size_t vfs_fread (gpointer ptr,size_t size,size_t nmemb, VFSFile *file);
Reads from a VFS stream.
|
A pointer to the destination buffer. |
|
The size of each element to read. |
|
The number of elements to read. |
|
VFSFile object that represents the VFS stream. |
Returns : |
The amount of elements succesfully read. |
size_t vfs_fwrite (gconstpointer ptr,size_t size,size_t nmemb, VFSFile *file);
Writes to a VFS stream.
|
A const pointer to the source buffer. |
|
The size of each element to write. |
|
The number of elements to write. |
|
VFSFile object that represents the VFS stream. |
Returns : |
The amount of elements succesfully written. |
gint vfs_getc (VFSFile *stream);
Reads a character from a VFS stream.
|
VFSFile object that represents the VFS stream. |
Returns : |
On success, a character. Otherwise, -1. |
gint vfs_ungetc (gint c, VFSFile *stream);
Pushes a character back to the VFS stream.
|
The character to push back. |
|
VFSFile object that represents the VFS stream. |
Returns : |
On success, 0. Otherwise, -1. |
gchar * vfs_fgets (gchar *s,gint n, VFSFile *stream);
Reads a set of characters from a stream.
|
A buffer to put the string in. |
|
The amount of characters to read. |
|
A VFSFile object representing the stream. |
Returns : |
The string on success, or NULL. |
gint vfs_fseek (VFSFile *file,glong offset,gint whence);
Seeks through a VFS stream.
|
VFSFile object that represents the VFS stream. |
|
The offset to seek to. |
|
Whether or not the seek is absolute or not. |
Returns : |
On success, 1. Otherwise, 0. |
void vfs_rewind (VFSFile *file);
Rewinds a VFS stream.
|
VFSFile object that represents the VFS stream. |
glong vfs_ftell (VFSFile *file);
Returns the current position in the VFS stream's buffer.
|
VFSFile object that represents the VFS stream. |
Returns : |
On success, the current position. Otherwise, -1. |
gboolean vfs_feof (VFSFile *file);
Returns whether or not the VFS stream has reached EOF.
|
VFSFile object that represents the VFS stream. |
Returns : |
On success, whether or not the VFS stream is at EOF. Otherwise, FALSE. |
gboolean vfs_file_test (constgchar *path,GFileTest test);
Wrapper for g_file_test()
|
A path to test. |
|
A GFileTest to run. |
Returns : |
The result of g_file_test() |
gboolean vfs_is_writeable (constgchar *path);
Tests if a file is writeable.
|
A path to test. |
Returns : |
TRUE if the file is writeable, otherwise FALSE. |
gboolean vfs_truncate (VFSFile *file,glong length);
Truncates a VFS stream to a certain size.
|
VFSFile object that represents the VFS stream. |
|
The length to truncate at. |
Returns : |
On success, 0. Otherwise, -1. |
gchar * vfs_get_metadata (VFSFile *file, constgchar *field);
Returns metadata about the stream.
|
VFSFile object that represents the VFS stream. |
|
The string constant field name to get. |
Returns : |
On success, a copy of the value of the field. Otherwise, NULL. |
int vfs_fprintf (VFSFile *stream,gchar const *format, ...);
Writes a formatted string to a VFS stream.
|
A VFSFile object representing the stream. |
|
A printf-style format string. |
|
A list of args to use. |
Returns : |
The amount of bytes written. |
gboolean vfs_register_transport (VFSConstructor *vtable);
Registers a VFSConstructor vtable with the VFS system.
|
The VFSConstructor vtable to register. |
Returns : |
TRUE on success, FALSE on failure. |