1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibC: Implement mkstemps() in stdlib and add a test

`mkstemps` generates a unique temporary file name from a pattern like
`prefixXXXXXXsuffix` where `prefix` and `suffix` can be any string with
only characters that are valid in a filename. The second parameter is
the length of the suffix.

`mkstemp` is `mkstemps` with suffix length 0, so to avoid code
duplication it calls `mkstemps`. It is unlikely this has any
significant performance impact on SerenityOS.

`generate_unique_filename` now takes the suffix length as a `size_t`.
The original behavior of this function is preserved when specifying a
suffix length of 0. All original uses of this function have been
adapted.

`mkstemps()` was added because it is required by version 4.6.3 of the
ccache port.
This commit is contained in:
EWouters 2022-09-03 19:35:47 +02:00 committed by Sam Atkins
parent 678d385a3f
commit 7c93eabffe
3 changed files with 68 additions and 6 deletions

View file

@ -58,6 +58,7 @@ double atof(char const*);
int system(char const* command);
char* mktemp(char*);
int mkstemp(char*);
int mkstemps(char*, int);
char* mkdtemp(char*);
void* bsearch(void const* key, void const* base, size_t nmemb, size_t size, int (*compar)(void const*, void const*));
int mblen(char const*, size_t);