fx.io: update interface implementations

This commit is contained in:
2026-05-25 17:30:33 +01:00
parent 97fe00d4a1
commit 74fbd94f95
3 changed files with 53 additions and 40 deletions
+18 -9
View File
@@ -6,6 +6,7 @@
#include <fx/io/file.h>
#include <fx/io/path.h>
#include <fx/string.h>
#include <fx/value.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -134,8 +135,8 @@ static enum fx_status path_get_directory(
size_t dir_path_len = (size_t)(sep - path_cstr);
fx_string *dir_path_s = fx_string_get_substr(path_str, 0, dir_path_len);
fx_path *dir_path
= fx_path_create_from_cstr(fx_string_get_cstr(dir_path_s));
fx_path *dir_path = fx_path_create_from_cstr(
fx_string_get_cstr(dir_path_s));
fx_string_unref(dir_path_s);
*out_dir_path = dir_path;
@@ -284,13 +285,15 @@ fx_path *fx_path_join(const fx_path *paths[], size_t nr_paths)
return NULL;
}
struct fx_path_p *result_p
= fx_object_get_private(result, FX_TYPE_PATH);
struct fx_path_p *result_p = fx_object_get_private(
result,
FX_TYPE_PATH);
for (size_t i = 0; i < nr_paths; i++) {
if (paths[i]) {
struct fx_path_p *path_p
= fx_object_get_private(paths[i], FX_TYPE_PATH);
struct fx_path_p *path_p = fx_object_get_private(
paths[i],
FX_TYPE_PATH);
append_path(result_p, path_p);
}
}
@@ -385,18 +388,24 @@ static void path_init(fx_object *obj, void *priv)
}
}
void path_fini(fx_object *obj, void *priv)
static void path_fini(fx_object *obj, void *priv)
{
struct fx_path_p *path = priv;
fx_string_unref(path->p_pathstr);
}
void path_to_string(const fx_object *obj, fx_stream *out)
static fx_status path_to_string(
const fx_value *obj,
fx_stream *out,
const char *format)
{
struct fx_path_p *path = fx_object_get_private(obj, FX_TYPE_PATH);
struct fx_path_p *path = fx_object_get_private(
obj->v_object,
FX_TYPE_PATH);
fx_stream_write_cstr(out, fx_string_get_cstr(path->p_pathstr), NULL);
return FX_SUCCESS;
}
/*** CLASS DEFINITION *********************************************************/