Functions¶
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
|
  | 
Details¶
- Gfls.finalize()¶
 Free the resources allocated by Gfls. For example it unrefs the singleton objects.
It is not mandatory to call this function, it’s just to be friendlier to memory debugging tools. This function is meant to be called at the end of main(). It can be called several times.
New in version 0.1.
- Gfls.init()¶
 Initializes the Gfls library (e.g. for the internationalization).
This function can be called several times, but is meant to be called at the beginning of main(), before any other Gfls function call.
New in version 0.1.
- Gfls.input_stream_read_async(input_stream, expected_size, max_size, io_priority, cancellable, callback, *user_data)¶
 - Parameters:
 input_stream (
Gio.InputStream) – aGio.InputStream.expected_size (
int) – the expected number of bytes contained in input_stream.max_size (
int) – the maximum number of bytes to read.io_priority (
int) – the I/O priority of the request. E.g.GLib.PRIORITY_LOW,GLib.PRIORITY_DEFAULTorGLib.PRIORITY_HIGH.cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore.callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the operation is finished.
This function starts a read operation on input_stream. It is meant to be used as the only read operation on input_stream, to get a
GLib.Bytesas a result, with max_size as the provided maximum number of bytes to read.expected_size is typically a
Gio.Filesize as returned byGio.FileInfo.get_size(). But note that in that case, the returnedGLib.Bytesmay contain a different number of bytes than what was expected (the TOC/TOU problem: time of check to time of use). expected_size is used as an indication to how much memory to allocate initially.See the
Gio.AsyncResultdocumentation to know how to use this function.New in version 0.1.
- Gfls.input_stream_read_finish(input_stream, result, is_truncated)¶
 - Parameters:
 input_stream (
Gio.InputStream) – aGio.InputStream.result (
Gio.AsyncResult) – aGio.AsyncResult.is_truncated (
bool) – will be set toTrueif the input_stream contains more data to be read, but the maximum number of bytes to read has been reached.
- Raises:
 - Returns:
 a
GLib.Bytes, orNoneon error.- Return type:
 
Finishes an operation started with
Gfls.input_stream_read_async().If is_truncated is set to
True, it is not an error (error is not set), and aGLib.Bytesis returned. However, sinceGfls.input_stream_read_async() is meant to be used as the only read operation on input_stream, it is an undefined behavior if you try to read more content from input_stream.The data contained in the resulting
GLib.Bytesis always zero-terminated, but this is not included in theGLib.Byteslength. The resultingGLib.Bytesshould be freed withGLib.Bytes.unref() when no longer in use.New in version 0.1.
- Gfls.loader_basic_load_async(file, max_size, max_n_bytes_per_line, io_priority, cancellable, callback, *user_data)¶
 - Parameters:
 max_size (
int) – the maximum allowed number of bytes in total.max_n_bytes_per_line (
int) – the maximum allowed number of bytes per line, as perGfls.utf8_find_very_long_line().io_priority (
int) – the I/O priority of the request. E.g.GLib.PRIORITY_LOW,GLib.PRIORITY_DEFAULTorGLib.PRIORITY_HIGH.cancellable (
Gio.CancellableorNone) – optionalGio.Cancellableobject,Noneto ignore.callback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the operation is finished.
Starts a basic file loading operation.
If the file content is not a valid UTF-8 string, or if the max_size or max_n_bytes_per_line conditions are not satisfied, an error will be returned without the file content.
See the
Gio.AsyncResultdocumentation to know how to use this function.New in version 0.1.
- Gfls.loader_basic_load_finish(file, result)¶
 - Parameters:
 result (
Gio.AsyncResult) – aGio.AsyncResult.
- Raises:
 - Returns:
 a
GLib.Bytes, orNoneon error.- Return type:
 
Finishes an operation started with
Gfls.loader_basic_load_async().If everything went well, a
GLib.Byteswith theGio.Filecontent (unmodified) is returned. It is guaranteed to be a valid UTF-8 string.Otherwise an error is returned. The %GFLS_LOADER_ERROR domain is used, among others.
The data contained in the resulting
GLib.Bytesis always zero-terminated, but this is not included in theGLib.Byteslength. The resultingGLib.Bytesshould be freed withGLib.Bytes.unref() when no longer in use.New in version 0.1.
- Gfls.utf8_find_very_long_line(str, max_n_bytes_per_line)¶
 - Parameters:
 - Returns:
 a pointer to the beginning of the first very long line found, or
Noneif not found.- Return type:
 
Finds if a line in str exceeds max_n_bytes_per_line.
For performance reasons, str is not checked whether it is a valid UTF-8 string. So you must call for example
GLib.utf8_validate() beforehand.New in version 0.3.