add threaded filewatcher

This commit is contained in:
2025-03-27 01:24:57 +02:00
parent 6d0cbbb011
commit 2015894068
20 changed files with 600 additions and 95 deletions

31
src/string/string.h Normal file
View File

@@ -0,0 +1,31 @@
#ifndef HI_STRING_H_
#define HI_STRING_H_
#include <stddef.h>
/**
* @brief Copy file content to a null terminated string, allocating memory while
* reading.
*
* This doesn't assume it can read file size, so it allocates memory in chunks
* (default 4096 bytes) and keeps reading until 0 bytes is read. If nmax is
* non-zero, instead that amount of bytes is allocated and that is read.
*
* In either case, the string is reallocated to match the length before
* returning.
* @param filename
* @param nread if not null, this will have the total amount bytes read
* @param nmax if not 0, this amount of memory in bytes is read and used as
* initial allocation
*/
const char *hi_string_from_file_dyn(const char *filename, size_t *nread,
size_t nmax);
/**
* Find if filename exists at the end of path.
*
* @return 0 if not found, positive if found
*/
int hi_path_has_filename(const char *path, const char *filename);
#endif // HI_STRING_H_