From d2d8e2fa52c5633f6376e4d3b1d7aca9a9ea14b0 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Tue, 25 Aug 2026 19:35:41 -0400 Subject: File fixes Signed-off-by: Andrew Opalach --- src/util/file/util.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/util/file/util.c') diff --git a/src/util/file/util.c b/src/util/file/util.c index 2f1fa36..0a42aad 100644 --- a/src/util/file/util.c +++ b/src/util/file/util.c @@ -1,5 +1,25 @@ #include "file.h" +void nn_path_append(str *path, str *part) +{ +#ifdef NAUNET_ON_WINDOWS + al_str_cat(path, &al_str_c("\\")); +#else + al_str_cat(path, &al_str_c("/")); +#endif + al_str_cat(path, part); +} + +void nn_path_prepend(str *path, str *part) +{ +#ifdef NAUNET_ON_WINDOWS + al_str_prepend(path, &al_str_c("\\")); +#else + al_str_prepend(path, &al_str_c("/")); +#endif + al_str_prepend(path, part); +} + s32 nn_file_read_as_str(struct nn_file *file, str *out) { size_t size = file->size; @@ -20,7 +40,7 @@ s32 nn_file_read_as_c_str(struct nn_file *file, char **out) al_free(*out); return -1; } - c_str[size] = '\n'; + c_str[size] = '\0'; *out = c_str; return size; } -- cgit v1.2.3-101-g0448