mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
u/file: Add u_file_read_content_from_path
Useful for Simula builder and North Star builder which both read straight from a path
This commit is contained in:
parent
a285294d7f
commit
d04139bedd
|
@ -154,3 +154,19 @@ u_file_read_content(FILE *file)
|
|||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char *
|
||||
u_file_read_content_from_path(const char *path)
|
||||
{
|
||||
FILE *file = fopen(path, "r");
|
||||
if (file == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
char *file_content = u_file_read_content(file);
|
||||
int ret = fclose(file);
|
||||
// We don't care about the return value since we're just reading
|
||||
(void)ret;
|
||||
|
||||
// Either valid non-null or null
|
||||
return file_content;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ u_file_get_runtime_dir(char *out_path, size_t out_path_size);
|
|||
char *
|
||||
u_file_read_content(FILE *file);
|
||||
|
||||
char *
|
||||
u_file_read_content_from_path(const char *path);
|
||||
|
||||
ssize_t
|
||||
u_file_get_path_in_runtime_dir(const char *suffix, char *out_path, size_t out_path_size);
|
||||
|
||||
|
|
Loading…
Reference in a new issue