X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Futil%2Fos_file.h;h=cf0dc2075952c23a942b33b8b00895947755c060;hb=ac55b1a9a6266b5badfee82d81302ffc38faeb42;hp=2f97c19ed5597d4dfbf427377bdd2cfcb4de014c;hpb=316964709e21286c2af54e3afb3089d0fcce87c1;p=mesa.git diff --git a/src/util/os_file.h b/src/util/os_file.h index 2f97c19ed55..cf0dc207595 100644 --- a/src/util/os_file.h +++ b/src/util/os_file.h @@ -8,16 +8,47 @@ #ifndef _OS_FILE_H_ #define _OS_FILE_H_ +#include +#include + #ifdef __cplusplus extern "C" { #endif +/* + * Create a new file and opens it for writing-only. + * If the given filename already exists, nothing is done and NULL is returned. + * `errno` gets set to the failure reason; if that is not EEXIST, the caller + * might want to do something other than trying again. + */ +FILE * +os_file_create_unique(const char *filename, int filemode); + +/* + * Duplicate a file descriptor, making sure not to keep it open after an exec*() + */ +int +os_dupfd_cloexec(int fd); + /* * Read a file. * Returns a char* that the caller must free(), or NULL and sets errno. + * If size is not null and no error occured it's set to the size of the + * file. */ char * -os_read_file(const char *filename); +os_read_file(const char *filename, size_t *size); + +/* + * Try to determine if two file descriptors reference the same file description + * + * Return values: + * - 0: They reference the same file description + * - > 0: They do not reference the same file description + * - < 0: Unable to determine whether they reference the same file description + */ +int +os_same_file_description(int fd1, int fd2); #ifdef __cplusplus }