Infinityd.FilesystemStorage¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The directory in which the storage stores its content |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Infinityd.FilesystemStorage(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new(root_directory)¶
- Parameters:
root_directory (
str
) – A directory name in UTF-8.- Returns:
A new
Infinityd.FilesystemStorage
.- Return type:
Creates a new
Infinityd.FilesystemStorage
that stores its nodes in the given directory on the file system. The directory is created if it does not exist.
- classmethod stream_close(file)¶
- Parameters:
file (
object
orNone
) – A #FILE opened withInfinityd.FilesystemStorage.open
().- Returns:
The return value of fclose().
- Return type:
This is a thin wrapper around fclose(). Use this function instead of fclose() if you have opened the file with
Infinityd.FilesystemStorage.open
(), to make sure that the same C runtime is closing the file that has opened it.
- classmethod stream_read(file)¶
- Parameters:
file (
object
orNone
) – A #FILE opened withInfinityd.FilesystemStorage.open
().- Returns:
The return value of fread().
- buffer:
A buffer into which to read data.
- Return type:
This is a thin wrapper around fread(). Use this function instead of fread() if you have opened the file with
Infinityd.FilesystemStorage.open
(), to make sure that the same C runtime is closing the file that has opened it.
- classmethod stream_write(file, buffer, len)¶
- Parameters:
- Returns:
The return value of fwrite().
- Return type:
This is a thin wrapper around fwrite(). Use this function instead of fwrite() if you have opened the file with
Infinityd.FilesystemStorage.open
(), to make sure that the same C runtime is closing the file that has opened it.
- get_path(identifier, path)¶
- Parameters:
- Raises:
- Returns:
An absolute filename path to be freed with
GLib.free
(), orNone
.- Return type:
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,
None
is returned and error is set.Only if identifier starts with “Inf”, the file will show up in the directory listing of
Infinityd.Storage.read_subdirectory
(). Other identifiers can be used to store custom data in the filesystem, linked to thisInfinityd.FilesystemStorage
object.
- open(identifier, path, mode)¶
- Parameters:
- Raises:
- Returns:
A stream for the open file. Close with
Infinityd.FilesystemStorage.stream_close
().- full_path:
Return location of the full filename, or
None
.
- Return type:
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
None
, 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
Infinityd.Storage.read_subdirectory
(). Other identifiers can be used to store custom data in the filesystem, linked to thisInfinityd.FilesystemStorage
object.
- write_xml_file(identifier, path, doc)¶
- Parameters:
identifier (
str
) – The type of node to write.path (
str
) – The path to write to, in UTF-8.doc (
libxml2.DocPtr
) – The XML document to write.
- Raises:
- Returns:
- Return type:
Writes the XML doument in doc into a file in the filesystem indicated by identifier and path. See
Infinityd.FilesystemStorage.open
() for how identifier and path should be interpreted.