meta: rename io module to fx.io namespace

This commit is contained in:
2026-05-02 14:37:29 +01:00
parent 47feee7b1a
commit 274a48a845
21 changed files with 0 additions and 0 deletions
View File
+75
View File
@@ -0,0 +1,75 @@
#ifndef FX_IO_DIRECTORY_H_
#define FX_IO_DIRECTORY_H_
#include <fx/core/error.h>
#include <fx/core/iterator.h>
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/io/file.h>
#include <fx/io/path.h>
#define FX_DIRECTORY_ROOT ((fx_directory *)NULL)
FX_DECLS_BEGIN;
struct fx_directory_p;
#define FX_TYPE_DIRECTORY (fx_directory_get_type())
#define FX_TYPE_DIRECTORY_ITERATOR (fx_directory_iterator_get_type())
FX_DECLARE_TYPE(fx_directory);
FX_DECLARE_TYPE(fx_directory_iterator);
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_directory)
FX_TYPE_CLASS_DECLARATION_END(fx_directory)
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_directory_iterator)
FX_TYPE_CLASS_DECLARATION_END(fx_directory_iterator)
struct z__fx_directory_iterator;
typedef enum fx_directory_iterator_flags {
FX_DIRECTORY_ITERATE_PARENT_FIRST = 0x01u,
FX_DIRECTORY_ITERATE_PARENT_LAST = 0x02u,
} fx_directory_iterator_flags;
typedef enum fx_directory_open_flags {
FX_DIRECTORY_OPEN_CREATE = 0x01u,
FX_DIRECTORY_OPEN_CREATE_INTERMEDIATE = 0x03u,
FX_DIRECTORY_OPEN_DELETE_ON_CLOSE = 0x04u,
} fx_directory_open_flags;
typedef struct fx_directory_entry {
const fx_path *filepath;
char *filename;
fx_file_info info;
} fx_directory_entry;
FX_API fx_type fx_directory_get_type(void);
FX_API fx_type fx_directory_iterator_get_type(void);
FX_API fx_result fx_directory_open(
fx_directory *root, const fx_path *path, fx_directory_open_flags flags,
fx_directory **out);
FX_API fx_result fx_directory_open_temp(fx_directory **out);
FX_API const fx_path *fx_directory_get_path(const fx_directory *dir);
FX_API const fx_path *fx_directory_get_rel_path(const fx_directory *dir);
FX_API const char *fx_directory_get_path_cstr(const fx_directory *dir);
FX_API const char *fx_directory_get_rel_path_cstr(const fx_directory *dir);
FX_API fx_result fx_directory_delete(fx_directory *dir);
FX_API bool fx_directory_path_exists(const fx_directory *root, const fx_path *path);
FX_API bool fx_directory_path_is_file(const fx_directory *root, const fx_path *path);
FX_API bool fx_directory_path_is_directory(
const fx_directory *root, const fx_path *path);
FX_API fx_result fx_directory_path_stat(
const fx_directory *root, const fx_path *path, struct fx_file_info *out);
FX_API fx_result fx_directory_path_unlink(
const fx_directory *root, const fx_path *path);
FX_API fx_iterator *fx_directory_begin(
fx_directory *dir, fx_directory_iterator_flags flags);
FX_DECLS_END;
#endif
+80
View File
@@ -0,0 +1,80 @@
#ifndef FX_IO_FILE_H_
#define FX_IO_FILE_H_
#include <fx/core/error.h>
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/stream.h>
FX_DECLS_BEGIN;
#define FX_TYPE_FILE (fx_file_get_type())
FX_DECLARE_TYPE(fx_file);
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_file)
FX_TYPE_CLASS_DECLARATION_END(fx_file)
#define FX_OFFSET_CURRENT ((size_t)-1)
typedef enum fx_seek_basis {
FX_SEEK_BEGINNING,
FX_SEEK_CURRENT,
FX_SEEK_END
} fx_seek_basis;
typedef enum fx_file_attribute {
FX_FILE_ATTRIB_NORMAL = 0x01u,
FX_FILE_ATTRIB_DIRECTORY = 0x02u,
FX_FILE_ATTRIB_BLOCK_DEVICE = 0x04u,
FX_FILE_ATTRIB_CHAR_DEVICE = 0x08u,
FX_FILE_ATTRIB_SYMLINK = 0x80u,
} fx_file_attribute;
typedef enum fx_file_mode {
FX_FILE_READ_ONLY = 0x01u,
FX_FILE_WRITE_ONLY = 0x02u,
FX_FILE_READ_WRITE = FX_FILE_READ_ONLY | FX_FILE_WRITE_ONLY,
FX_FILE_TRUNCATE = 0x04u,
FX_FILE_CREATE = 0x08u,
FX_FILE_CREATE_ONLY = 0x10u | FX_FILE_CREATE,
FX_FILE_APPEND = 0x20u,
FX_FILE_BINARY = 0x40u,
FX_FILE_DELETE_ON_CLOSE = 0x80u,
FX_FILE_SHADOW = 0x100u,
} fx_file_mode;
typedef struct fx_file_info {
fx_file_attribute attrib;
fx_file_mode mode;
size_t length;
} fx_file_info;
FX_API fx_type fx_file_get_type(void);
FX_API fx_result fx_file_open(
FX_TYPE_FWDREF(fx_directory) * root, const FX_TYPE_FWDREF(fx_path) * path,
fx_file_mode mode, fx_file **out);
FX_API fx_result fx_file_open_temp(fx_file_mode mode, fx_file **out);
FX_API fx_result fx_file_open_shadow(
fx_file *original, fx_file_mode mode, fx_file **out);
FX_API fx_status fx_file_stat(fx_file *file, fx_file_info *out);
FX_API fx_status fx_file_size(fx_file *file, size_t *out_len);
FX_API fx_status fx_file_cursor(fx_file *file, size_t *out_pos);
FX_API fx_status fx_file_resize(fx_file *file, size_t len);
FX_API fx_status fx_file_seek(fx_file *file, long long offset, fx_seek_basis basis);
FX_API const FX_TYPE_FWDREF(fx_path) * fx_file_path(const fx_file *file);
FX_API fx_status fx_file_swap_shadow(fx_file *main_file, fx_file *shadow_file);
FX_API fx_status fx_file_read(
fx_file *file, size_t offset, size_t len, void *buf, size_t *nr_read);
FX_API fx_status fx_file_write(
fx_file *file, size_t offset, size_t len, const void *buf,
size_t *nr_written);
FX_DECLS_END;
#endif
+54
View File
@@ -0,0 +1,54 @@
#ifndef FX_IO_PATH_H_
#define FX_IO_PATH_H_
#include <fx/core/macros.h>
#include <fx/core/misc.h>
#include <fx/core/status.h>
#include <fx/ds/string.h>
#include <stddef.h>
FX_DECLS_BEGIN;
#define FX_TYPE_PATH (fx_path_get_type())
FX_DECLARE_TYPE(fx_path);
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_path)
FX_TYPE_CLASS_DECLARATION_END(fx_path)
#define FX_RV_PATH(cstr) FX_RV(fx_path_create_from_cstr(cstr))
struct fx_file_info;
FX_API fx_type 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_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_make_absolute(const fx_path *in);
FX_API fx_path *fx_path_make_relative(const fx_path *in);
FX_API fx_path *fx_path_make_canonical(const fx_path *in);
FX_API bool fx_path_is_absolute(const fx_path *path);
FX_API bool fx_path_exists(const fx_path *path);
FX_API bool fx_path_is_file(const fx_path *path);
FX_API bool fx_path_is_directory(const fx_path *path);
FX_API fx_status fx_path_stat(const fx_path *path, struct fx_file_info *out);
FX_API fx_status fx_path_unlink(const fx_path *path);
FX_API enum fx_status fx_path_get_directory(
const fx_path *path, fx_path **out_dir_path);
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 size_t fx_path_length(const fx_path *path);
FX_DECLS_END;
#endif