io: file: convert to new object system
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
#ifndef BLUELIB_IO_FILE_H_
|
||||
#define BLUELIB_IO_FILE_H_
|
||||
#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>
|
||||
#include <blue/ds/object.h>
|
||||
|
||||
#define B_FILE(p) ((b_file *)(p))
|
||||
B_DECLS_BEGIN;
|
||||
|
||||
#define B_OFFSET_CURRENT ((size_t) - 1)
|
||||
#define B_TYPE_FILE (b_file_get_type())
|
||||
|
||||
struct b_directory;
|
||||
struct b_path;
|
||||
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,
|
||||
@@ -47,11 +51,11 @@ typedef struct b_file_info {
|
||||
size_t length;
|
||||
} b_file_info;
|
||||
|
||||
typedef struct b_file b_file;
|
||||
BLUE_API b_type b_file_get_type(void);
|
||||
|
||||
BLUE_API b_result b_file_open(
|
||||
struct b_directory *root, const struct b_path *path, b_file_mode mode,
|
||||
b_file **out);
|
||||
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);
|
||||
@@ -62,7 +66,7 @@ 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 struct b_path *b_file_path(const b_file *file);
|
||||
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);
|
||||
|
||||
@@ -72,13 +76,6 @@ BLUE_API b_status b_file_write(
|
||||
b_file *file, size_t offset, size_t len, const void *buf,
|
||||
size_t *nr_written);
|
||||
|
||||
static inline b_file *b_file_retain(b_file *file)
|
||||
{
|
||||
return B_FILE(b_retain(B_DSREF(file)));
|
||||
}
|
||||
static inline void b_file_release(b_file *file)
|
||||
{
|
||||
b_release(B_DSREF(file));
|
||||
}
|
||||
B_DECLS_END;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user