meta: add module for disk I/O functionality
This commit is contained in:
0
io/include/blue/io.h
Normal file
0
io/include/blue/io.h
Normal file
34
io/include/blue/io/directory.h
Normal file
34
io/include/blue/io/directory.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef BLUELIB_IO_DIRECTORY_H_
|
||||
#define BLUELIB_IO_DIRECTORY_H_
|
||||
|
||||
#include <blue/core/iterator.h>
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
|
||||
#define B_DIRECTORY_ROOT ((b_directory *)NULL)
|
||||
|
||||
typedef struct b_directory b_directory;
|
||||
|
||||
struct z__b_directory_iterator;
|
||||
|
||||
typedef struct b_directory_iterator {
|
||||
b_iterator _base;
|
||||
char *filename;
|
||||
char *filepath;
|
||||
struct z__b_directory_iterator *_z;
|
||||
} b_directory_iterator;
|
||||
|
||||
#define b_directory_foreach(it, dir, flags) \
|
||||
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 char *path, b_directory **out);
|
||||
|
||||
BLUE_API int b_directory_iterator_begin(
|
||||
b_directory *directory, b_directory_iterator *it);
|
||||
BLUE_API bool b_directory_iterator_next(b_directory_iterator *it);
|
||||
BLUE_API b_status b_directory_iterator_erase(b_directory_iterator *it);
|
||||
BLUE_API bool b_directory_iterator_is_valid(const b_directory_iterator *it);
|
||||
|
||||
#endif
|
||||
25
io/include/blue/io/path.h
Normal file
25
io/include/blue/io/path.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef BLUELIB_IO_PATH_H_
|
||||
#define BLUELIB_IO_PATH_H_
|
||||
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/core/status.h>
|
||||
#include <blue/object/object.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct b_path b_path;
|
||||
|
||||
BLUE_API b_status b_path_create(b_path **out);
|
||||
BLUE_API b_status b_path_create_root(b_path **out);
|
||||
BLUE_API b_status b_path_create_cwd(b_path **out);
|
||||
BLUE_API b_status b_path_create_from_cstr(const char *path, b_path **out);
|
||||
|
||||
BLUE_API b_status b_path_join(const b_path *paths[], size_t nr_paths, b_path **out);
|
||||
|
||||
BLUE_API b_status b_path_make_absolute(const b_path *in, b_path **out);
|
||||
BLUE_API b_status b_path_make_relative(const b_path *in, b_path **out);
|
||||
BLUE_API b_status b_path_make_canonical(const b_path *in, b_path **out);
|
||||
|
||||
BLUE_API b_path *b_path_retain(b_path *path);
|
||||
BLUE_API void b_path_release(b_path *path);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user