| Midgard 2.0 Reference Manual | ||||
|---|---|---|---|---|
typedef MidgardBlob; typedef MidgardBlobClass; MidgardBlobPrivate; MidgardBlob* midgard_blob_new (MgdObject *attachment); gchar* midgard_blob_read_content (MidgardBlob *self, gsize *bytes_read); gboolean midgard_blob_write_content (MidgardBlob *self, const gchar *content); GIOChannel* midgard_blob_get_handler (MidgardBlob *self); const gchar* midgard_blob_get_path (MidgardBlob *self); gboolean midgard_blob_exists (MidgardBlob *self); gboolean midgard_blob_remove_file (MidgardBlob *self);
MidgardBlob* midgard_blob_new (MgdObject *attachment);
Instatiate new Midgard Blob object for the given midgard_attachment object. This is almost the same constructor as g_object_new, but unlike that one, midgard_blob_new requires MgdObject (midgard_attachment) object's pointer.
This constructor defines new relative path for attachment, if midgard_attachment is associated with midgard_blob and its location is empty. In any other case, location is not changed.
|
MgdObject of MIDGARD_TYPE_ATTACHMENT type. |
Returns : |
newly instatiated MidgardBlob object or NULL on failure
|
gchar* midgard_blob_read_content (MidgardBlob *self, gsize *bytes_read);
Returned content should be freed when no longer needed.
bytes_read holds size of returned content.
This function should be used to get content of small files. For large and huge ones midgard_blob_get_handler should be used to get file handle.
|
MidgardBlob self instance |
|
number of bytes read |
Returns : |
content of the file, or NULL on failure
|
gboolean midgard_blob_write_content (MidgardBlob *self, const gchar *content);
Write given content to a file.
|
MidgardBlob self instance. |
|
content which should be written to file. |
Returns : |
TRUE if content has been written to file, FALSE otherwise.
|
GIOChannel* midgard_blob_get_handler (MidgardBlob *self);
The main idea is to get file handler. On C level it returns GIOChannel, but language bindings could return typical file handler or anything else which is needed for particular language.
Returned channel is owned by midgard_blob and should not be freed or unreferenced.
|
MidgardBlob instance |
Returns : |
GIOChannel or NULL
|
const gchar* midgard_blob_get_path (MidgardBlob *self);
Returned path is owned by midgard_blob and should not be freed. It basically contains blobdir and relative file's location.
|
MidgardBlob instance |
Returns : |
absolute path or NULL if path is not set yet.
|
gboolean midgard_blob_exists (MidgardBlob *self);
Check if file associated with midgard_blob exists. This function will also return FALSE, if file is not yet associated.
|
MidgardBlob instance |
Returns : |
TRUE if file exists, FALSE otherwise
|
gboolean midgard_blob_remove_file (MidgardBlob *self);
Deletes a file which is associated with blob and located at attachment's location which is initialized for blob. midgard_blob_exists should be invoked if file may be already deleted, for example when one file is shared among many attachments.
|
MidgardBlob self instance. |
Returns : |
TRUE on success, FALSE otherwise
|