io: implement b_error support for file/directory operations
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#ifndef BLUELIB_IO_DIRECTORY_H_
|
||||
#define BLUELIB_IO_DIRECTORY_H_
|
||||
|
||||
#include <blue/core/error.h>
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/io/file.h>
|
||||
#include <blue/io/path.h>
|
||||
|
||||
@@ -19,6 +19,11 @@ typedef enum b_directory_iterator_flags {
|
||||
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_flags;
|
||||
|
||||
typedef struct b_directory_iterator {
|
||||
b_iterator _base;
|
||||
struct z__b_directory_iterator *_z;
|
||||
@@ -35,17 +40,21 @@ typedef struct b_directory_iterator {
|
||||
for (int z__b_unique_name() = b_directory_iterator_begin(dir, it, flags); \
|
||||
b_directory_iterator_is_valid(it); b_directory_iterator_next(it))
|
||||
|
||||
BLUE_API b_status b_directory_open(
|
||||
b_directory *root, const b_path *path, b_directory **out);
|
||||
BLUE_API b_result b_directory_open(
|
||||
b_directory *root, const b_path *path, b_directory_open_flags flags,
|
||||
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 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_status b_directory_path_stat(
|
||||
BLUE_API b_result b_directory_path_stat(
|
||||
const b_directory *root, const b_path *path, struct b_file_info *out);
|
||||
BLUE_API b_status b_directory_path_unlink(
|
||||
BLUE_API b_result b_directory_path_unlink(
|
||||
const b_directory *root, const b_path *path);
|
||||
|
||||
BLUE_API int b_directory_iterator_begin(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef BLUELIB_IO_FILE_H_
|
||||
#define BLUELIB_IO_FILE_H_
|
||||
|
||||
#include <blue/core/error.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/core/stream.h>
|
||||
#include <blue/object/object.h>
|
||||
|
||||
@@ -49,11 +49,11 @@ typedef struct b_file_info {
|
||||
|
||||
typedef struct b_file b_file;
|
||||
|
||||
BLUE_API b_status b_file_open(
|
||||
BLUE_API b_result b_file_open(
|
||||
struct b_directory *root, const struct b_path *path, b_file_mode mode,
|
||||
b_file **out);
|
||||
BLUE_API b_status b_file_open_temp(b_file_mode mode, b_file **out);
|
||||
BLUE_API b_status b_file_open_shadow(
|
||||
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_open_stream(b_file *file, b_stream **out);
|
||||
|
||||
Reference in New Issue
Block a user