![]() |
![]() |
![]() |
GSK Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
gboolean gsk_mkdir_p (const char *dir, guint permissions, GError **error); gboolean gsk_rm_rf (const char *dir_or_file, GError **error); char * gsk_escape_memory (gconstpointer data, guint len); gpointer gsk_unescape_memory (const char *quoted, gboolean has_quote_marks, const char **end, guint *length_out, GError **error); char * gsk_escape_memory_hex (gconstpointer data, guint len); guint8 * gsk_unescape_memory_hex (const char *str, gssize len, gsize *length_out, GError **error); void gsk_fd_set_close_on_exec (int fd, gboolean close_on_exec); gboolean gsk_fd_clear_nonblocking (int fd); gboolean gsk_fd_is_nonblocking (int fd); gssize gsk_readn (guint fd, void *buf, gsize len); gssize gsk_writen (guint fd, const void *buf, gsize len);
gboolean gsk_mkdir_p (const char *dir, guint permissions, GError **error);
Make a directory and any nonexistant parent directories.
This parallels the unix command 'mkdir -p DIR'.
|
the directory to make. |
|
file creation mode for the directory and its subdirectories. |
|
where to put an error, if one occurs. |
Returns : |
whether the directory now exists. Note that this function returns TRUE if the directory existed on startup. |
gboolean gsk_rm_rf (const char *dir_or_file, GError **error);
Recursively remove a directory or file, similar to 'rm -rf DIR_OR_FILE' on the unix command-line.
|
the directory or file to delete. |
|
optional error return location. |
Returns : |
whether the removal was successful. This routine fails if there is a permission or i/o problem. (It returns TRUE if the file does not exist.) If it fails, and error is non-NULL, *error will hold a GError object. |
char * gsk_escape_memory (gconstpointer data, guint len);
Convert a bunch of memory to something suitable for addition into a C string.
|
raw data to C-escape. |
|
length of raw data in bytes |
Returns : |
a newly allocated string of escaped data. |
gpointer gsk_unescape_memory (const char *quoted, gboolean has_quote_marks, const char **end, guint *length_out, GError **error);
Take a C double-quoted string and make it into a suitable for addition into a C string.
|
C-string to unquote. |
|
whether to strip off double-quotes. |
|
where to store the end of the quoted string (right past the last double-quote. |
|
where to store the length of the unquoted memory. |
|
optional error return location. |
Returns : |
a newly allocated string of raw data, which an extra NUL postpended, so that it can be used as a string. |
char * gsk_escape_memory_hex (gconstpointer data, guint len);
Convert a bunch of memory to its hex dump.
|
raw data to dump as hex |
|
length of raw data in bytes |
Returns : |
a newly allocated string of hex digits. |
guint8 * gsk_unescape_memory_hex (const char *str, gssize len, gsize *length_out, GError **error);
Converts an even-number of hex digits into a binary set of bytes, and returns the bytes. Even if the data is length 0, you must free the return value.
If NULL is returned, it means an error occurred.
|
the memory dump as a string. |
|
the maximum length of the string, or -1 to use NUL-termination. |
|
length of the returned memory. |
|
where to put an error, if one occurs. |
Returns : |
the binary data. |
void gsk_fd_set_close_on_exec (int fd, gboolean close_on_exec);
This function sets the value of the close-on-exec flag for a file-descriprtor.
Most files will be closed on the exec system call, but normally 0,1,2 (standard input, output and error) are set not to close-on-exec, which is why they are always inherited.
|
the file-descriptor to affect. |
|
whether the close the file-descriptor on exec(2). |
gssize gsk_readn (guint fd, void *buf, gsize len);
Read data from fd, retrying the read if not enough data is found. This is only for blocking reads.
|
the file-descriptor to read from. |
|
the buffer to fill. |
|
number of bytes to read from fd. |
Returns : |
the number of bytes read or -1 if an error occurs. |
gssize gsk_writen (guint fd, const void *buf, gsize len);
Write data to fd, retrying the write if not enough data is sent. This is only for blocking writes.
|
the file-descriptor to write to. |
|
the buffer to read from. |
|
number of bytes to write to fd. |
Returns : |
the number of bytes written or -1 if an error occurs. |