fx.io: expand path joining functionality to non-path strings

This commit is contained in:
2026-06-20 15:25:16 +01:00
parent 32d4d0abf2
commit ee11ff240f
10 changed files with 239 additions and 151 deletions
+11 -4
View File
@@ -18,18 +18,25 @@ FX_TYPE_CLASS_DECLARATION_END(fx_path)
#define FX_RV_PATH(cstr) FX_RV(fx_path_create_from_cstr(cstr))
typedef enum fx_system_path {
FX_PATH_ROOT = 0,
FX_PATH_CWD,
FX_PATH_HOME,
FX_PATH_CONFIG,
} fx_system_path;
struct fx_file_info;
FX_API fx_type_id fx_path_get_type(void);
FX_TYPE_DEFAULT_CONSTRUCTOR(fx_path, FX_TYPE_PATH);
FX_API fx_path *fx_path_create_root();
FX_API fx_path *fx_path_create_cwd();
FX_API fx_path *fx_path_create_from_cstr(const char *path);
FX_API fx_path *fx_path_get_system(fx_system_path path_type);
FX_API fx_path *fx_path_duplicate(const fx_path *path);
FX_API fx_path *fx_path_join(const fx_path *paths[], size_t nr_paths);
FX_API fx_path *fx_path_join_array(const fx_value *values[], size_t nr_values);
FX_API fx_path *fx_path_join_list(size_t count, ...);
FX_API fx_path *fx_path_make_absolute(const fx_path *in);
FX_API fx_path *fx_path_make_relative(const fx_path *in);
@@ -49,7 +56,7 @@ FX_API enum fx_status fx_path_get_filename(
const fx_path *path,
fx_string *out_name);
FX_API const char *fx_path_ptr(const fx_path *path);
FX_API const char *fx_path_get_cstr(const fx_path *path);
FX_API size_t fx_path_length(const fx_path *path);
FX_DECLS_END;
+4 -4
View File
@@ -51,12 +51,12 @@ static const fx_path *directory_get_rel_path(const struct fx_directory_p *dir)
static const char *directory_get_path_cstr(const struct fx_directory_p *dir)
{
return fx_path_ptr(dir->d_path_abs);
return fx_path_get_cstr(dir->d_path_abs);
}
static const char *directory_get_rel_path_cstr(const struct fx_directory_p *dir)
{
return fx_path_ptr(dir->d_path_rel);
return fx_path_get_cstr(dir->d_path_rel);
}
static fx_result directory_delete(
@@ -263,7 +263,7 @@ static fx_result directory_open(
int root_fd = root ? root->d_fd : AT_FDCWD;
const char *path_cstr = fx_path_ptr(path);
const char *path_cstr = fx_path_get_cstr(path);
if (root) {
while (*path_cstr == '/') {
path_cstr++;
@@ -571,7 +571,7 @@ fx_iterator *fx_directory_begin(
int fts_flags = FTS_COMFOLLOW | FTS_NOCHDIR;
const char *path_list[] = {
fx_path_ptr(it->_p->d_path_abs),
fx_path_get_cstr(it->_p->d_path_abs),
NULL,
};
+5 -5
View File
@@ -248,11 +248,11 @@ static enum fx_status file_swap_shadow(
int err;
err = rename(fx_path_ptr(main_file->path), fx_path_ptr(tmp_path));
err = rename(fx_path_get_cstr(main_file->path), fx_path_get_cstr(tmp_path));
err = rename(
fx_path_ptr(shadow_file->path),
fx_path_ptr(main_file->path));
err = rename(fx_path_ptr(tmp_path), fx_path_ptr(shadow_file->path));
fx_path_get_cstr(shadow_file->path),
fx_path_get_cstr(main_file->path));
err = rename(fx_path_get_cstr(tmp_path), fx_path_get_cstr(shadow_file->path));
fx_path_unref(tmp_path);
@@ -441,7 +441,7 @@ fx_result fx_file_open(
return FX_RESULT_ERR(NO_MEMORY);
}
int fd = open(fx_path_ptr(abs_path), flags, 0644);
int fd = open(fx_path_get_cstr(abs_path), flags, 0644);
if (fd == -1) {
fx_path_unref(abs_path);
return FX_RESULT_STATUS(
+55 -42
View File
@@ -41,7 +41,7 @@ static bool path_is_absolute(const struct fx_path_p *path)
return s[0] == '/';
}
static const char *path_ptr(const struct fx_path_p *path)
static const char *path_get_cstr(const struct fx_path_p *path)
{
return fx_string_get_cstr(path->p_pathstr);
}
@@ -51,7 +51,7 @@ static enum fx_status path_stat(
struct fx_file_info *out)
{
struct stat st;
int err = stat(path_ptr(path), &st);
int err = stat(path_get_cstr(path), &st);
if (err != 0) {
return fx_status_from_errno(errno, FX_ERR_IO_FAILURE);
@@ -135,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;
@@ -200,33 +200,6 @@ fx_path *fx_path_create_root()
return path;
}
fx_path *fx_path_create_cwd()
{
const long buf_len = 2048;
char *buf = malloc(buf_len);
if (!buf) {
return NULL;
}
if (!getcwd(buf, buf_len)) {
free(buf);
return NULL;
}
fx_path *path = fx_path_create();
if (!path) {
free(buf);
return NULL;
}
struct fx_path_p *p = fx_object_get_private(path, FX_TYPE_PATH);
fx_string_append_cstr(p->p_pathstr, buf);
free(buf);
return path;
}
fx_path *fx_path_create_from_cstr(const char *cstr)
{
fx_path *path = fx_path_create();
@@ -259,6 +232,49 @@ fx_path *fx_path_create_from_cstr(const char *cstr)
return path;
}
fx_path *fx_path_get_system(fx_system_path path_type)
{
char path_buf[4096];
const char *path_value = NULL, *default_value = NULL;
switch (path_type) {
case FX_PATH_ROOT:
path_value = "/";
break;
case FX_PATH_CWD:
if (getcwd(path_buf, sizeof path_buf) == NULL) {
path_value = path_buf;
}
break;
case FX_PATH_HOME:
path_value = getenv("HOME");
default_value = "~";
break;
case FX_PATH_CONFIG: {
const char *home = getenv("HOME");
path_value = getenv("XDG_CONFIG_HOME");
snprintf(
path_buf,
sizeof path_buf,
"%s/.config",
home ? home : "~");
default_value = path_buf;
break;
}
default:
return NULL;
}
if (path_value) {
return fx_path_create_from_cstr(path_value);
}
if (default_value) {
return fx_path_create_from_cstr(default_value);
}
return NULL;
}
fx_path *fx_path_duplicate(const fx_path *path)
{
fx_path *new_path = fx_path_create();
@@ -285,15 +301,13 @@ 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);
}
}
@@ -366,9 +380,9 @@ enum fx_status fx_path_get_filename(const fx_path *path, fx_string *out_name)
out_name);
}
const char *fx_path_ptr(const fx_path *path)
const char *fx_path_get_cstr(const fx_path *path)
{
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_PATH, path_ptr, path);
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_PATH, path_get_cstr, path);
}
size_t fx_path_length(const fx_path *path)
@@ -400,9 +414,8 @@ static fx_status path_to_string(
fx_stream *out,
const char *format)
{
struct fx_path_p *path = fx_object_get_private(
obj->v_object,
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;
+35 -29
View File
@@ -53,12 +53,12 @@ static const fx_path *directory_get_rel_path(const struct fx_directory_p *dir)
static const char *directory_get_path_cstr(const struct fx_directory_p *dir)
{
return fx_path_ptr(dir->d_path_abs);
return fx_path_get_cstr(dir->d_path_abs);
}
static const char *directory_get_rel_path_cstr(const struct fx_directory_p *dir)
{
return fx_path_ptr(dir->d_path_rel);
return fx_path_get_cstr(dir->d_path_rel);
}
static fx_result directory_delete(
@@ -90,12 +90,13 @@ static bool directory_path_exists(
const struct fx_directory_p *root,
const fx_path *path)
{
const fx_path *parts[] = {
root ? root->d_path_abs : NULL,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : NULL),
&FX_VALUE_OBJECT(path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!abs_path) {
return false;
}
@@ -110,12 +111,13 @@ static bool directory_path_is_file(
const struct fx_directory_p *root,
const fx_path *path)
{
const fx_path *parts[] = {
root ? root->d_path_abs : NULL,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : NULL),
&FX_VALUE_OBJECT(path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!abs_path) {
return false;
}
@@ -130,12 +132,13 @@ static bool directory_path_is_directory(
const struct fx_directory_p *root,
const fx_path *path)
{
const fx_path *parts[] = {
root ? root->d_path_abs : NULL,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : NULL),
&FX_VALUE_OBJECT(path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!abs_path) {
return false;
}
@@ -151,12 +154,13 @@ static fx_result directory_path_stat(
const fx_path *path,
struct fx_file_info *out)
{
const fx_path *parts[] = {
root ? root->d_path_abs : NULL,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : NULL),
&FX_VALUE_OBJECT(path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!abs_path) {
return FX_RESULT_ERR(NO_MEMORY);
}
@@ -171,12 +175,13 @@ static fx_result directory_path_unlink(
const struct fx_directory_p *root,
const fx_path *path)
{
const fx_path *parts[] = {
root ? root->d_path_abs : NULL,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : NULL),
&FX_VALUE_OBJECT(path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!abs_path) {
return FX_RESULT_ERR(NO_MEMORY);
}
@@ -264,7 +269,7 @@ static fx_result directory_open(
int root_fd = root ? root->d_fd : AT_FDCWD;
const char *path_cstr = fx_path_ptr(path);
const char *path_cstr = fx_path_get_cstr(path);
if (root) {
while (*path_cstr == '/') {
path_cstr++;
@@ -298,15 +303,16 @@ static fx_result directory_open(
= fx_object_get_private(dir, FX_TYPE_DIRECTORY);
if (!root) {
cwd = fx_path_create_cwd();
cwd = fx_path_get_system(FX_PATH_CWD);
}
const fx_path *parts[] = {
root ? root->d_path_abs : cwd,
path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root ? root->d_path_abs : cwd),
&FX_VALUE_OBJECT(path),
};
fx_path *new_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *new_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (!new_path) {
return FX_RESULT_ERR(NO_MEMORY);
}
@@ -570,7 +576,7 @@ fx_iterator *fx_directory_begin(
int fts_flags = FTS_COMFOLLOW | FTS_NOCHDIR;
const char *path_list[] = {
fx_path_ptr(it->_p->d_path_abs),
fx_path_get_cstr(it->_p->d_path_abs),
NULL,
};
+25 -18
View File
@@ -86,13 +86,13 @@ static fx_result file_open_shadow(
= fx_path_create_from_cstr(fx_string_get_cstr(filename));
fx_string_unref(filename);
const fx_path *parts[] = {
dir,
shadow_filename,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(dir),
&FX_VALUE_OBJECT(shadow_filename),
};
fx_path *shadow_filepath
= fx_path_join(parts, sizeof parts / sizeof parts[0]);
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
fx_path_unref(dir);
fx_path_unref(shadow_filename);
@@ -229,12 +229,14 @@ static enum fx_status file_swap_shadow(
z__fx_io_generate_tmp_filename(tmp_name, sizeof tmp_name);
fx_path *tmp_name_p = fx_path_create_from_cstr(tmp_name);
const fx_path *parts[] = {
dir_path,
tmp_name_p,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(dir_path),
&FX_VALUE_OBJECT(tmp_name_p),
};
tmp_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
tmp_path = fx_path_join_array(
parts,
sizeof parts / sizeof parts[0]);
fx_path_unref(tmp_name_p);
@@ -250,11 +252,15 @@ static enum fx_status file_swap_shadow(
int err;
err = rename(fx_path_ptr(main_file->path), fx_path_ptr(tmp_path));
err = rename(
fx_path_ptr(shadow_file->path),
fx_path_ptr(main_file->path));
err = rename(fx_path_ptr(tmp_path), fx_path_ptr(shadow_file->path));
fx_path_get_cstr(main_file->path),
fx_path_get_cstr(tmp_path));
err = rename(
fx_path_get_cstr(shadow_file->path),
fx_path_get_cstr(main_file->path));
err = rename(
fx_path_get_cstr(tmp_path),
fx_path_get_cstr(shadow_file->path));
fx_path_unref(tmp_path);
@@ -424,16 +430,17 @@ fx_result fx_file_open(
if (root) {
root_path = fx_directory_get_path(root);
} else {
root_path = fx_path_create_cwd();
root_path = fx_path_get_system(FX_PATH_CWD);
free_root_path = true;
}
const fx_path *parts[] = {
root_path,
file_path,
const fx_value *parts[] = {
&FX_VALUE_OBJECT(root_path),
&FX_VALUE_OBJECT(file_path),
};
fx_path *abs_path = fx_path_join(parts, sizeof parts / sizeof parts[0]);
fx_path *abs_path
= fx_path_join_array(parts, sizeof parts / sizeof parts[0]);
if (free_root_path) {
fx_path_unref((fx_path *)root_path);
@@ -443,7 +450,7 @@ fx_result fx_file_open(
return FX_RESULT_ERR(NO_MEMORY);
}
int fd = open(fx_path_ptr(abs_path), flags, 0644);
int fd = open(fx_path_get_cstr(abs_path), flags, 0644);
if (fd == -1) {
fx_path_unref(abs_path);
return FX_RESULT_STATUS(
+96 -41
View File
@@ -91,22 +91,22 @@ static bool path_is_directory(const struct fx_path_p *path)
return (info.attrib & FX_FILE_ATTRIB_DIRECTORY) != 0;
}
static void append_path(struct fx_path_p *dest, const struct fx_path_p *src)
static void append_path(struct fx_path_p *dest, const fx_string *src)
{
if (path_is_absolute(src)) {
const char *src_cstr = fx_string_get_cstr(src);
if (src_cstr[0] == '/') {
fx_string_clear(dest->p_pathstr);
fx_string_append_s(dest->p_pathstr, src->p_pathstr);
fx_string_append_s(dest->p_pathstr, src);
return;
}
if (fx_string_get_size(dest->p_pathstr, FX_STRLEN_NORMAL) > 0
&& fx_string_get_last_char(dest->p_pathstr) != '/'
&& fx_string_get_first_char(src->p_pathstr) != '/') {
char s[] = {'/', 0};
fx_string_append_cstr(dest->p_pathstr, s);
&& fx_string_get_first_char(src) != '/') {
fx_string_append_c(dest->p_pathstr, '/');
}
fx_string_append_s(dest->p_pathstr, src->p_pathstr);
fx_string_append_s(dest->p_pathstr, src);
}
static enum fx_status path_unlink(const struct fx_path_p *path)
@@ -199,33 +199,6 @@ fx_path *fx_path_create_root()
return path;
}
fx_path *fx_path_create_cwd()
{
const long buf_len = 2048;
char *buf = malloc(buf_len);
if (!buf) {
return NULL;
}
if (!getcwd(buf, buf_len)) {
free(buf);
return NULL;
}
fx_path *path = fx_path_create();
if (!path) {
free(buf);
return NULL;
}
struct fx_path_p *p = fx_object_get_private(path, FX_TYPE_PATH);
fx_string_append_cstr(p->p_pathstr, buf);
free(buf);
return path;
}
fx_path *fx_path_create_from_cstr(const char *cstr)
{
fx_path *path = fx_path_create();
@@ -258,6 +231,49 @@ fx_path *fx_path_create_from_cstr(const char *cstr)
return path;
}
fx_path *fx_path_get_system(fx_system_path path_type)
{
char path_buf[4096];
const char *path_value = NULL, *default_value = NULL;
switch (path_type) {
case FX_PATH_ROOT:
path_value = "/";
break;
case FX_PATH_CWD:
if (getcwd(path_buf, sizeof path_buf) == NULL) {
path_value = path_buf;
}
break;
case FX_PATH_HOME:
path_value = getenv("HOME");
default_value = "~";
break;
case FX_PATH_CONFIG: {
const char *home = getenv("HOME");
path_value = getenv("XDG_CONFIG_HOME");
snprintf(
path_buf,
sizeof path_buf,
"%s/.config",
home ? home : "~");
default_value = path_buf;
break;
}
default:
return NULL;
}
if (path_value) {
return fx_path_create_from_cstr(path_value);
}
if (default_value) {
return fx_path_create_from_cstr(default_value);
}
return NULL;
}
fx_path *fx_path_duplicate(const fx_path *path)
{
fx_path *new_path = fx_path_create();
@@ -277,7 +293,7 @@ fx_path *fx_path_duplicate(const fx_path *path)
return new_path;
}
fx_path *fx_path_join(const fx_path *paths[], size_t nr_paths)
fx_path *fx_path_join_array(const fx_value *values[], size_t nr_values)
{
fx_path *result = fx_path_create();
if (!result) {
@@ -287,14 +303,53 @@ fx_path *fx_path_join(const fx_path *paths[], size_t nr_paths)
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);
append_path(result_p, path_p);
fx_stringstream *tmp = fx_stringstream_create();
fx_string *value_s = fx_string_create();
for (size_t i = 0; i < nr_values; i++) {
if (!values[i]) {
continue;
}
fx_stringstream_reset(tmp);
fx_value_to_string(values[i], tmp, NULL);
fx_string_clear(value_s);
fx_string_append_cstr(value_s, fx_stringstream_get_cstr(tmp));
append_path(result_p, value_s);
}
fx_string_unref(value_s);
fx_stringstream_unref(tmp);
return result;
}
fx_path *fx_path_join_list(size_t count, ...)
{
fx_path *result = fx_path_create();
if (!result) {
return NULL;
}
struct fx_path_p *result_p
= fx_object_get_private(result, FX_TYPE_PATH);
va_list arg;
va_start(arg, count);
fx_stringstream *tmp = fx_stringstream_create();
fx_string *value_s = fx_string_create();
for (size_t i = 0; i < count; i++) {
const fx_value *value = va_arg(arg, const fx_value *);
fx_stringstream_reset(tmp);
fx_value_to_string(value, tmp, NULL);
fx_string_clear(value_s);
fx_string_append_cstr(value_s, fx_stringstream_get_cstr(tmp));
append_path(result_p, value_s);
}
fx_string_unref(value_s);
fx_stringstream_unref(tmp);
return result;
}
@@ -363,7 +418,7 @@ enum fx_status fx_path_get_filename(const fx_path *path, fx_string *out_name)
out_name);
}
const char *fx_path_ptr(const fx_path *path)
const char *fx_path_get_cstr(const fx_path *path)
{
FX_CLASS_DISPATCH_STATIC_0(FX_TYPE_PATH, path_ptr, path);
}
+3 -3
View File
@@ -60,7 +60,7 @@ enum fx_status fx_directory_open(
}
HANDLE dir_handle = CreateFileA(
fx_path_ptr(new_path), GENERIC_READ,
fx_path_get_cstr(new_path), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, INVALID_HANDLE_VALUE);
@@ -197,7 +197,7 @@ static bool move_into_directory(struct fx_directory_iterator *it, const char *di
state = push_iteration_state(it->_z);
state->search_path = dir_path;
state->search = FindFirstFileA(fx_path_ptr(search_path), &state->data);
state->search = FindFirstFileA(fx_path_get_cstr(search_path), &state->data);
fx_path_release(search_path);
fx_path_release(wildcard);
@@ -224,7 +224,7 @@ static bool move_into_directory(struct fx_directory_iterator *it, const char *di
static bool move_to_first_item(
struct fx_directory_iterator *it, const struct fx_path *root_dir)
{
bool has_results = move_into_directory(it, fx_path_ptr(root_dir));
bool has_results = move_into_directory(it, fx_path_get_cstr(root_dir));
if (!has_results) {
return false;
+4 -4
View File
@@ -205,13 +205,13 @@ bool fx_path_is_absolute(const struct fx_path *path)
bool fx_path_exists(const struct fx_path *path)
{
DWORD attrib = GetFileAttributesA(fx_path_ptr(path));
DWORD attrib = GetFileAttributesA(fx_path_get_cstr(path));
return attrib != INVALID_FILE_ATTRIBUTES;
}
bool fx_path_is_file(const struct fx_path *path)
{
DWORD attrib = GetFileAttributesA(fx_path_ptr(path));
DWORD attrib = GetFileAttributesA(fx_path_get_cstr(path));
if (attrib == INVALID_FILE_ATTRIBUTES) {
return false;
}
@@ -221,7 +221,7 @@ bool fx_path_is_file(const struct fx_path *path)
bool fx_path_is_directory(const struct fx_path *path)
{
DWORD attrib = GetFileAttributesA(fx_path_ptr(path));
DWORD attrib = GetFileAttributesA(fx_path_get_cstr(path));
if (attrib == INVALID_FILE_ATTRIBUTES) {
return false;
}
@@ -229,7 +229,7 @@ bool fx_path_is_directory(const struct fx_path *path)
return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
const char *fx_path_ptr(const struct fx_path *path)
const char *fx_path_get_cstr(const struct fx_path *path)
{
return fx_string_get_cstr(path->pathstr);
}
+1 -1
View File
@@ -27,7 +27,7 @@ int main(int argc, const char **argv)
{
fx_directory_entry *entry = NULL;
fx_value_get_pointer(val, (void **)&entry);
printf("%s\n", fx_path_ptr(entry->filepath));
printf("%s\n", fx_path_get_cstr(entry->filepath));
}
fx_iterator_unref(it);