meta: rename to fx
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
#ifndef BLUE_IO_DIRECTORY_H_
|
||||
#define BLUE_IO_DIRECTORY_H_
|
||||
|
||||
#include <blue/core/error.h>
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/io/file.h>
|
||||
#include <blue/io/path.h>
|
||||
|
||||
#define B_DIRECTORY_ROOT ((b_directory *)NULL)
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
struct b_directory_p;
|
||||
|
||||
#define B_TYPE_DIRECTORY (b_directory_get_type())
|
||||
#define B_TYPE_DIRECTORY_ITERATOR (b_directory_iterator_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_directory);
|
||||
B_DECLARE_TYPE(b_directory_iterator);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_directory)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_directory)
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_directory_iterator)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_directory_iterator)
|
||||
|
||||
struct z__b_directory_iterator;
|
||||
|
||||
typedef enum b_directory_iterator_flags {
|
||||
B_DIRECTORY_ITERATE_PARENT_FIRST = 0x01u,
|
||||
B_DIRECTORY_ITERATE_PARENT_LAST = 0x02u,
|
||||
} b_directory_iterator_flags;
|
||||
|
||||
typedef enum b_directory_open_flags {
|
||||
B_DIRECTORY_OPEN_CREATE = 0x01u,
|
||||
B_DIRECTORY_OPEN_CREATE_INTERMEDIATE = 0x03u,
|
||||
B_DIRECTORY_OPEN_DELETE_ON_CLOSE = 0x04u,
|
||||
} b_directory_open_flags;
|
||||
|
||||
typedef struct b_directory_entry {
|
||||
const b_path *filepath;
|
||||
char *filename;
|
||||
b_file_info info;
|
||||
} b_directory_entry;
|
||||
|
||||
BLUE_API b_type b_directory_get_type(void);
|
||||
BLUE_API b_type b_directory_iterator_get_type(void);
|
||||
|
||||
BLUE_API b_result b_directory_open(
|
||||
b_directory *root, const b_path *path, b_directory_open_flags flags,
|
||||
b_directory **out);
|
||||
BLUE_API b_result b_directory_open_temp(b_directory **out);
|
||||
BLUE_API const b_path *b_directory_get_path(const b_directory *dir);
|
||||
BLUE_API const b_path *b_directory_get_rel_path(const b_directory *dir);
|
||||
BLUE_API const char *b_directory_get_path_cstr(const b_directory *dir);
|
||||
BLUE_API const char *b_directory_get_rel_path_cstr(const b_directory *dir);
|
||||
BLUE_API b_result b_directory_delete(b_directory *dir);
|
||||
|
||||
BLUE_API bool b_directory_path_exists(const b_directory *root, const b_path *path);
|
||||
BLUE_API bool b_directory_path_is_file(const b_directory *root, const b_path *path);
|
||||
BLUE_API bool b_directory_path_is_directory(
|
||||
const b_directory *root, const b_path *path);
|
||||
BLUE_API b_result b_directory_path_stat(
|
||||
const b_directory *root, const b_path *path, struct b_file_info *out);
|
||||
BLUE_API b_result b_directory_path_unlink(
|
||||
const b_directory *root, const b_path *path);
|
||||
|
||||
BLUE_API b_iterator *b_directory_begin(
|
||||
b_directory *dir, b_directory_iterator_flags flags);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
@@ -1,80 +0,0 @@
|
||||
#ifndef BLUE_IO_FILE_H_
|
||||
#define BLUE_IO_FILE_H_
|
||||
|
||||
#include <blue/core/error.h>
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/stream.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_FILE (b_file_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_file);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_file)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_file)
|
||||
|
||||
#define B_OFFSET_CURRENT ((size_t)-1)
|
||||
|
||||
typedef enum b_seek_basis {
|
||||
B_SEEK_BEGINNING,
|
||||
B_SEEK_CURRENT,
|
||||
B_SEEK_END
|
||||
} b_seek_basis;
|
||||
|
||||
typedef enum b_file_attribute {
|
||||
B_FILE_ATTRIB_NORMAL = 0x01u,
|
||||
B_FILE_ATTRIB_DIRECTORY = 0x02u,
|
||||
B_FILE_ATTRIB_BLOCK_DEVICE = 0x04u,
|
||||
B_FILE_ATTRIB_CHAR_DEVICE = 0x08u,
|
||||
B_FILE_ATTRIB_SYMLINK = 0x80u,
|
||||
} b_file_attribute;
|
||||
|
||||
typedef enum b_file_mode {
|
||||
B_FILE_READ_ONLY = 0x01u,
|
||||
B_FILE_WRITE_ONLY = 0x02u,
|
||||
B_FILE_READ_WRITE = B_FILE_READ_ONLY | B_FILE_WRITE_ONLY,
|
||||
B_FILE_TRUNCATE = 0x04u,
|
||||
B_FILE_CREATE = 0x08u,
|
||||
B_FILE_CREATE_ONLY = 0x10u | B_FILE_CREATE,
|
||||
B_FILE_APPEND = 0x20u,
|
||||
B_FILE_BINARY = 0x40u,
|
||||
B_FILE_DELETE_ON_CLOSE = 0x80u,
|
||||
B_FILE_SHADOW = 0x100u,
|
||||
} b_file_mode;
|
||||
|
||||
typedef struct b_file_info {
|
||||
b_file_attribute attrib;
|
||||
b_file_mode mode;
|
||||
|
||||
size_t length;
|
||||
} b_file_info;
|
||||
|
||||
BLUE_API b_type b_file_get_type(void);
|
||||
|
||||
BLUE_API b_result b_file_open(
|
||||
B_TYPE_FWDREF(b_directory) * root, const B_TYPE_FWDREF(b_path) * path,
|
||||
b_file_mode mode, b_file **out);
|
||||
BLUE_API b_result b_file_open_temp(b_file_mode mode, b_file **out);
|
||||
BLUE_API b_result b_file_open_shadow(
|
||||
b_file *original, b_file_mode mode, b_file **out);
|
||||
|
||||
BLUE_API b_status b_file_stat(b_file *file, b_file_info *out);
|
||||
BLUE_API b_status b_file_size(b_file *file, size_t *out_len);
|
||||
BLUE_API b_status b_file_cursor(b_file *file, size_t *out_pos);
|
||||
BLUE_API b_status b_file_resize(b_file *file, size_t len);
|
||||
BLUE_API b_status b_file_seek(b_file *file, long long offset, b_seek_basis basis);
|
||||
BLUE_API const B_TYPE_FWDREF(b_path) * b_file_path(const b_file *file);
|
||||
|
||||
BLUE_API b_status b_file_swap_shadow(b_file *main_file, b_file *shadow_file);
|
||||
|
||||
BLUE_API b_status b_file_read(
|
||||
b_file *file, size_t offset, size_t len, void *buf, size_t *nr_read);
|
||||
BLUE_API b_status b_file_write(
|
||||
b_file *file, size_t offset, size_t len, const void *buf,
|
||||
size_t *nr_written);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
#ifndef BLUE_IO_PATH_H_
|
||||
#define BLUE_IO_PATH_H_
|
||||
|
||||
#include <blue/core/macros.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/ds/string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_TYPE_PATH (b_path_get_type())
|
||||
|
||||
B_DECLARE_TYPE(b_path);
|
||||
|
||||
B_TYPE_CLASS_DECLARATION_BEGIN(b_path)
|
||||
B_TYPE_CLASS_DECLARATION_END(b_path)
|
||||
|
||||
#define B_RV_PATH(cstr) B_RV(b_path_create_from_cstr(cstr))
|
||||
|
||||
struct b_file_info;
|
||||
|
||||
BLUE_API b_type b_path_get_type(void);
|
||||
|
||||
B_TYPE_DEFAULT_CONSTRUCTOR(b_path, B_TYPE_PATH);
|
||||
|
||||
BLUE_API b_path *b_path_create_root();
|
||||
BLUE_API b_path *b_path_create_cwd();
|
||||
BLUE_API b_path *b_path_create_from_cstr(const char *path);
|
||||
BLUE_API b_path *b_path_duplicate(const b_path *path);
|
||||
|
||||
BLUE_API b_path *b_path_join(const b_path *paths[], size_t nr_paths);
|
||||
|
||||
BLUE_API b_path *b_path_make_absolute(const b_path *in);
|
||||
BLUE_API b_path *b_path_make_relative(const b_path *in);
|
||||
BLUE_API b_path *b_path_make_canonical(const b_path *in);
|
||||
|
||||
BLUE_API bool b_path_is_absolute(const b_path *path);
|
||||
BLUE_API bool b_path_exists(const b_path *path);
|
||||
BLUE_API bool b_path_is_file(const b_path *path);
|
||||
BLUE_API bool b_path_is_directory(const b_path *path);
|
||||
BLUE_API b_status b_path_stat(const b_path *path, struct b_file_info *out);
|
||||
BLUE_API b_status b_path_unlink(const b_path *path);
|
||||
|
||||
BLUE_API enum b_status b_path_get_directory(
|
||||
const b_path *path, b_path **out_dir_path);
|
||||
BLUE_API enum b_status b_path_get_filename(const b_path *path, b_string *out_name);
|
||||
|
||||
BLUE_API const char *b_path_ptr(const b_path *path);
|
||||
BLUE_API size_t b_path_length(const b_path *path);
|
||||
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user