io: path: convert to new object system

This commit is contained in:
2025-10-19 21:00:26 +01:00
parent 5e850a4a53
commit 5f660a4a4e
2 changed files with 309 additions and 228 deletions

View File

@@ -1,20 +1,29 @@
#ifndef BLUELIB_IO_PATH_H_
#define BLUELIB_IO_PATH_H_
#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/object.h>
#include <blue/ds/string.h>
#include <stddef.h>
#define B_PATH(p) ((b_path *)p)
B_DECLS_BEGIN;
#define B_RV_PATH(cstr) B_PATH(B_RV(b_path_create_from_cstr(cstr)))
#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;
typedef struct b_path b_path;
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();
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);
@@ -35,20 +44,11 @@ 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, struct b_string *out_name);
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);
static inline b_path *b_path_retain(b_path *path)
{
return B_PATH(b_retain(B_DSREF(path)));
}
static inline void b_path_release(b_path *path)
{
b_release(B_DSREF(path));
}
B_DECLS_END;
#endif