fx.io: convert to assembly build system

This commit is contained in:
2026-05-03 14:51:11 +01:00
parent 55ba15b1fa
commit cefb548824
18 changed files with 657 additions and 258 deletions
+29 -12
View File
@@ -1,11 +1,11 @@
#include "posix.h"
#include <fx/ds/string.h>
#include <fx/io/file.h>
#include <fx/io/path.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <fx/io/file.h>
#include <fx/io/path.h>
#include <fx/string.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -45,7 +45,9 @@ static const char *path_ptr(const struct fx_path_p *path)
return fx_string_get_cstr(path->p_pathstr);
}
static enum fx_status path_stat(const struct fx_path_p *path, struct fx_file_info *out)
static enum fx_status path_stat(
const struct fx_path_p *path,
struct fx_file_info *out)
{
struct stat st;
int err = stat(path_ptr(path), &st);
@@ -110,11 +112,13 @@ static void append_path(struct fx_path_p *dest, const struct fx_path_p *src)
static enum fx_status path_unlink(const struct fx_path_p *path)
{
int err = remove(fx_string_get_cstr(path->p_pathstr));
return err == 0 ? FX_SUCCESS : fx_status_from_errno(errno, FX_ERR_IO_FAILURE);
return err == 0 ? FX_SUCCESS
: fx_status_from_errno(errno, FX_ERR_IO_FAILURE);
}
static enum fx_status path_get_directory(
const struct fx_path_p *path, fx_path **out_dir_path)
const struct fx_path_p *path,
fx_path **out_dir_path)
{
fx_string *path_str = path->p_pathstr;
long len = fx_string_get_size(path_str, FX_STRLEN_NORMAL);
@@ -130,7 +134,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;
@@ -139,7 +144,8 @@ static enum fx_status path_get_directory(
}
static enum fx_status path_get_filename(
const struct fx_path_p *path, fx_string *out_name)
const struct fx_path_p *path,
fx_string *out_name)
{
fx_string *path_str = path->p_pathstr;
long len = fx_string_get_size(path_str, FX_STRLEN_NORMAL);
@@ -278,7 +284,8 @@ 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]) {
@@ -336,14 +343,24 @@ enum fx_status fx_path_unlink(const fx_path *path)
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_PATH, path_unlink, path);
}
enum fx_status fx_path_get_directory(const fx_path *path, fx_path **out_dir_path)
enum fx_status fx_path_get_directory(
const fx_path *path,
fx_path **out_dir_path)
{
FX_CLASS_DISPATCH_STATIC(FX_TYPE_PATH, path_get_directory, path, out_dir_path);
FX_CLASS_DISPATCH_STATIC(
FX_TYPE_PATH,
path_get_directory,
path,
out_dir_path);
}
enum fx_status fx_path_get_filename(const fx_path *path, fx_string *out_name)
{
FX_CLASS_DISPATCH_STATIC(FX_TYPE_PATH, path_get_filename, path, out_name);
FX_CLASS_DISPATCH_STATIC(
FX_TYPE_PATH,
path_get_filename,
path,
out_name);
}
const char *fx_path_ptr(const fx_path *path)