![]() |
![]() |
![]() |
libinfinity-0.6 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
enum InfdFilesystemStorageError; InfdFilesystemStorage; struct InfdFilesystemStorageClass; InfdFilesystemStorage * infd_filesystem_storage_new (const gchar *root_directory
); gchar * infd_filesystem_storage_get_path (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,GError **error
); FILE * infd_filesystem_storage_open (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,const gchar *mode
,gchar **full_path
,GError **error
); xmlDocPtr infd_filesystem_storage_read_xml_file (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,const gchar *toplevel_tag
,GError **error
); gboolean infd_filesystem_storage_write_xml_file (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,xmlDocPtr doc
,GError **error
); int infd_filesystem_storage_stream_close (FILE *file
); gsize infd_filesystem_storage_stream_read (FILE *file
,gpointer buffer
,gsize len
); gsize infd_filesystem_storage_stream_write (FILE *file
,gconstpointer buffer
,gsize len
);
typedef enum { /* The path contains invalid characters */ INFD_FILESYSTEM_STORAGE_ERROR_INVALID_PATH, /* Failed to remove files from disk */ INFD_FILESYSTEM_STORAGE_ERROR_REMOVE_FILES, /* File has invaild format */ INFD_FILESYSTEM_STORAGE_ERROR_INVALID_FORMAT, INFD_FILESYSTEM_STORAGE_ERROR_FAILED } InfdFilesystemStorageError;
InfdFilesystemStorage * infd_filesystem_storage_new (const gchar *root_directory
);
Creates a new InfdFilesystemStorage that stores its nodes in the given directory on the file system. The directory is created if it does not exist.
|
A directory name in UTF-8. |
Returns : |
A new InfdFilesystemStorage. |
gchar * infd_filesystem_storage_get_path (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,GError **error
);
Returns the full file name to the given path within the storage's root
directory. The function might fail if path
contains invalid characters.
If the function fails, NULL
is returned and error
is set.
Only if identifier
starts with "Inf", the file will show up in
the directory listing of infd_storage_read_subdirectory()
. Other
identifiers can be used to store custom data in the filesystem, linked to
this InfdFilesystemStorage object.
|
A InfdFilesystemStorage. |
|
The type of node to open. |
|
The path to open, in UTF-8. |
|
Location to store error information, if any, or NULL . |
Returns : |
An absolute filename path to be freed with g_free() , or NULL . |
FILE * infd_filesystem_storage_open (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,const gchar *mode
,gchar **full_path
,GError **error
);
Opens a file in the given path within the storage's root directory. If
the file exists already, and mode
is set to "w", the file is overwritten.
If full_path
is not NULL
, then it will be set to a newly allocated
string which contains the full name of the opened file, in the Glib file
name encoding. Note that full_path
will also be set if the function fails.
Only if identifier
starts with "Inf", the file will show up in
the directory listing of infd_storage_read_subdirectory()
. Other
identifiers can be used to store custom data in the filesystem, linked to
this InfdFilesystemStorage object.
|
A InfdFilesystemStorage. |
|
The type of node to open. |
|
The path to open, in UTF-8. |
|
Either "r" for reading or "w" for writing. |
|
Return location of the full filename, or NULL . |
|
Location to store error information, if any. |
Returns : |
A stream for the open file. Close with
infd_filesystem_storage_stream_close() . |
xmlDocPtr infd_filesystem_storage_read_xml_file (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,const gchar *toplevel_tag
,GError **error
);
Opens a file in the given path, and parses its XML content. See
infd_filesystem_storage_open()
for how identifier
and path
should be
interpreted.
If toplevel_tag
is non-NULL
, then this function generates an error if
the XML document read has a toplevel tag with a different name.
|
A InfdFilesystemStorage. |
|
The type of node to open. |
|
The path to open, in UTF-8. |
|
The expected toplevel XML tag name, or NULL . |
|
Location to store error information, if any. |
Returns : |
A new XML document, or NULL on error. Free with xmlDocFree() . |
gboolean infd_filesystem_storage_write_xml_file (InfdFilesystemStorage *storage
,const gchar *identifier
,const gchar *path
,xmlDocPtr doc
,GError **error
);
Writes the XML doument in doc
into a file in the filesystem indicated
by identifier
and path
. See infd_filesystem_storage_open()
for how
identifier
and path
should be interpreted.
|
A InfdFilesystemStorage. |
|
The type of node to write. |
|
The path to write to, in UTF-8. |
|
The XML document to write. |
|
Location to store error information, if any. |
Returns : |
TRUE on success or FALSE on error. |
int infd_filesystem_storage_stream_close
(FILE *file
);
This is a thin wrapper around fclose()
. Use this function instead of
fclose()
if you have opened the file with infd_filesystem_storage_open()
,
to make sure that the same C runtime is closing the file that has opened
it.
|
A FILE opened with infd_filesystem_storage_open() . |
Returns : |
The return value of fclose() . |
gsize infd_filesystem_storage_stream_read (FILE *file
,gpointer buffer
,gsize len
);
This is a thin wrapper around fread()
. Use this function instead of
fread()
if you have opened the file with infd_filesystem_storage_open()
,
to make sure that the same C runtime is closing the file that has opened
it.
|
A FILE opened with infd_filesystem_storage_open() . |
|
A buffer into which to read data. |
|
Maximum number of bytes to read. |
Returns : |
The return value of fread() . |
gsize infd_filesystem_storage_stream_write (FILE *file
,gconstpointer buffer
,gsize len
);
This is a thin wrapper around fwrite()
. Use this function instead of
fwrite()
if you have opened the file with infd_filesystem_storage_open()
,
to make sure that the same C runtime is closing the file that has opened
it.
|
A FILE opened with infd_filesystem_storage_open() . |
|
The data to write. |
|
Maximum number of bytes to write. |
Returns : |
The return value of fwrite() . |
"root-directory"
property"root-directory" gchar* : Read / Write / Construct Only
The directory in which the storage stores its content.
Default value: NULL