util: add os_file_create_unique()
[mesa.git] / src / util / os_file.h
1 /*
2 * Copyright 2019 Intel Corporation
3 * SPDX-License-Identifier: MIT
4 *
5 * File operations helpers
6 */
7
8 #ifndef _OS_FILE_H_
9 #define _OS_FILE_H_
10
11 #include <stdio.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 /*
18 * Create a new file and opens it for writing-only.
19 * If the given filename already exists, nothing is done and NULL is returned.
20 * `errno` gets set to the failure reason; if that is not EEXIST, the caller
21 * might want to do something other than trying again.
22 */
23 FILE *
24 os_file_create_unique(const char *filename, int filemode);
25
26 /*
27 * Read a file.
28 * Returns a char* that the caller must free(), or NULL and sets errno.
29 */
30 char *
31 os_read_file(const char *filename);
32
33 #ifdef __cplusplus
34 }
35 #endif
36
37 #endif /* _OS_FILE_H_ */