Top | ![]() |
![]() |
![]() |
![]() |
InfdFilesystemStorage * | infd_filesystem_storage_new () |
gchar * | infd_filesystem_storage_get_path () |
FILE * | infd_filesystem_storage_open () |
xmlDocPtr | infd_filesystem_storage_read_xml_file () |
gboolean | infd_filesystem_storage_write_xml_file () |
int | infd_filesystem_storage_stream_close () |
gsize | infd_filesystem_storage_stream_read () |
gsize | infd_filesystem_storage_stream_write () |
enum | InfdFilesystemStorageError |
struct | InfdFilesystemStorage |
struct | InfdFilesystemStorageClass |
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.
[constructor]
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.
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.
storage |
||
identifier |
The type of node to open. |
|
path |
The path to open, in UTF-8. |
|
mode |
Either "r" for reading or "w" for writing. |
|
full_path |
Return location
of the full filename, or |
[out][type filename][transfer full] |
error |
Location to store error information, if any. |
A stream for the open file. Close with
infd_filesystem_storage_stream_close()
.
[transfer full]
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.
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.
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.
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.
file |
A FILE opened with |
|
buffer |
A buffer into which to read data. |
[type guint8*][array length=len][out] |
len |
Maximum number of bytes to read. |
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.
file |
A FILE opened with |
|
buffer |
The data to write. |
|
len |
Maximum number of bytes to write. |