## gskutils

gskutils —

## Synopsis

    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);
    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);

## Description

## Details

### gsk_mkdir_p ()

    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'.

`dir` : | the directory to make.
`permissions` : | file creation mode for the directory and its subdirectories.
`error` : | 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.

### gsk_rm_rf ()

    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.

`dir_or_file` : | the directory or file to delete.
`error` : | optional error return location.
Returns : | whether the removal was successful. This routine fails if the dir_or_file does not exist, or if there is a permission or i/o problem. If it fails, and error is non-NULL, *error will hold a GError object.

### gsk_escape_memory ()

    char*       gsk_escape_memory               (gconstpointer data,
                                                 guint len);

Convert a bunch of memory to something suitable for addition into a C string.

`data` : | raw data to C-escape.
`len` : | length of raw data in bytes
Returns : | a newly allocated string of escaped data.

### gsk_escape_memory_hex ()

    char*       gsk_escape_memory_hex           (gconstpointer data,
                                                 guint len);

Convert a bunch of memory to its hex dump.

`data` : | raw data to dump as hex
`len` : | length of raw data in bytes
Returns : | a newly allocated string of hex digits.

### gsk_unescape_memory_hex ()

    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.

`str` : | the memory dump as a string.
`len` : | the maximum length of the string, or -1 to use NUL-termination.
`length_out` : | length of the returned memory.
`error` : | where to put an error, if one occurs.
Returns : | the binary data.

### gsk_fd_set_close_on_exec ()

    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.

`fd` : | the file-descriptor to affect.
`close_on_exec` : | whether the close the file-descriptor on exec(2).