io: directory: implement temporary directories and delete-on-close

This commit is contained in:
2025-08-09 19:40:11 +01:00
parent 655d8b1881
commit 8bdb770ae5
5 changed files with 127 additions and 22 deletions

21
io/sys/darwin/misc.c Normal file
View File

@@ -0,0 +1,21 @@
#include "misc.h"
#include <blue/core/random.h>
void z__b_io_generate_tmp_filename(char *out, size_t len)
{
static const char *alphabet
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
"01234567"
"89+=-_.";
static const size_t alphabet_len = 67;
b_random_ctx *ctx = b_random_global_ctx();
for (size_t i = 0; i < len; i++) {
int v = b_random_next_int64(ctx) % alphabet_len;
out[i] = alphabet[v];
}
out[len - 1] = 0;
}