io: add linux support
This commit is contained in:
+11
-11
@@ -36,13 +36,13 @@ static fx_path *path_make_canonical(const struct fx_path_p *in)
|
||||
|
||||
static bool path_is_absolute(const struct fx_path_p *path)
|
||||
{
|
||||
const char *s = fx_string_ptr(path->p_pathstr);
|
||||
const char *s = fx_string_get_cstr(path->p_pathstr);
|
||||
return s[0] == '/';
|
||||
}
|
||||
|
||||
static const char *path_ptr(const struct fx_path_p *path)
|
||||
{
|
||||
return fx_string_ptr(path->p_pathstr);
|
||||
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)
|
||||
@@ -98,8 +98,8 @@ static void append_path(struct fx_path_p *dest, const struct fx_path_p *src)
|
||||
}
|
||||
|
||||
if (fx_string_get_size(dest->p_pathstr, FX_STRLEN_NORMAL) > 0
|
||||
&& fx_string_back(dest->p_pathstr) != '/'
|
||||
&& fx_string_front(src->p_pathstr) != '/') {
|
||||
&& 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);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ 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_ptr(path->p_pathstr));
|
||||
int err = remove(fx_string_get_cstr(path->p_pathstr));
|
||||
return err == 0 ? FX_SUCCESS : fx_status_from_errno(errno, FX_ERR_IO_FAILURE);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ static enum fx_status path_get_directory(
|
||||
fx_string *path_str = path->p_pathstr;
|
||||
long len = fx_string_get_size(path_str, FX_STRLEN_NORMAL);
|
||||
|
||||
const char *path_cstr = fx_string_ptr(path_str);
|
||||
const char *path_cstr = fx_string_get_cstr(path_str);
|
||||
char *sep = strrchr(path_cstr, '/');
|
||||
|
||||
if (!sep) {
|
||||
@@ -128,9 +128,9 @@ static enum fx_status path_get_directory(
|
||||
}
|
||||
|
||||
size_t dir_path_len = (size_t)(sep - path_cstr);
|
||||
fx_string *dir_path_s = fx_string_substr(path_str, 0, dir_path_len);
|
||||
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_ptr(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;
|
||||
@@ -144,7 +144,7 @@ static enum fx_status path_get_filename(
|
||||
fx_string *path_str = path->p_pathstr;
|
||||
long len = fx_string_get_size(path_str, FX_STRLEN_NORMAL);
|
||||
|
||||
char *sep = strrchr(fx_string_ptr(path_str), '/');
|
||||
char *sep = strrchr(fx_string_get_cstr(path_str), '/');
|
||||
|
||||
if (!sep) {
|
||||
fx_string_append_s(out_name, path_str);
|
||||
@@ -245,7 +245,7 @@ fx_path *fx_path_create_from_cstr(const char *cstr)
|
||||
prev = c;
|
||||
}
|
||||
|
||||
while (fx_string_back(p->p_pathstr) == '/') {
|
||||
while (fx_string_get_last_char(p->p_pathstr) == '/') {
|
||||
fx_string_pop_back(p->p_pathstr);
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ void path_to_string(const fx_object *obj, fx_stream *out)
|
||||
{
|
||||
struct fx_path_p *path = fx_object_get_private(obj, FX_TYPE_PATH);
|
||||
|
||||
fx_stream_write_cstr(out, fx_string_ptr(path->p_pathstr), NULL);
|
||||
fx_stream_write_cstr(out, fx_string_get_cstr(path->p_pathstr), NULL);
|
||||
}
|
||||
|
||||
/*** CLASS DEFINITION *********************************************************/
|
||||
|
||||
Reference in New Issue
Block a user