![]() |
![]() |
![]() |
PolicyKit Library Reference Manual | ![]() |
---|---|---|---|---|
kit_bool_t kit_file_get_contents (const char *path, char **out_contents, size_t *out_contents_size); kit_bool_t kit_file_set_contents (const char *path, mode_t mode, const char *contents, size_t contents_size);
kit_bool_t kit_file_get_contents (const char *path, char **out_contents, size_t *out_contents_size);
Reads an entire file into allocated memory.
|
path to file |
|
Return location for allocated memory. Free with kit_free() .
|
|
Return location for size of the file. |
Returns : |
TRUE if the file was read into memory; FALSE if an error occured and errno will be set. On OOM, errno will be set to ENOMEM. If the file doesn't exist, errno will be set to ENOENT. |
kit_bool_t kit_file_set_contents (const char *path, mode_t mode, const char *contents, size_t contents_size);
Writes all of contents to a file named path
, with good error
checking. If a file called path
already exists it will be
overwritten. This write is atomic in the sense that it is first
written to a temporary file which is then renamed to the final
name.
If the file already exists hard links to path
will break. Also
since the file is recreated, existing permissions, access control
lists, metadata etc. may be lost. If path
is a symbolic link, the
link itself will be replaced, not the linked file.