meta: add module for disk I/O functionality
This commit is contained in:
@@ -5,7 +5,7 @@ include (TestBigEndian)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
set(b_modules core object term cmd)
|
||||
set(b_modules core object term cmd io)
|
||||
|
||||
set(b_system_name ${CMAKE_SYSTEM_NAME})
|
||||
string(TOLOWER ${b_system_name} b_system_name)
|
||||
|
||||
3
io/CMakeLists.txt
Normal file
3
io/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
include(../cmake/Templates.cmake)
|
||||
|
||||
add_bluelib_module(NAME io DEPENDENCIES core)
|
||||
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
|
||||
39
io/sys/darwin/directory.c
Normal file
39
io/sys/darwin/directory.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <blue/io/directory.h>
|
||||
#include <fts.h>
|
||||
|
||||
struct b_directory {
|
||||
int fd;
|
||||
char *abs_path;
|
||||
};
|
||||
|
||||
struct z__b_directory_iterator {
|
||||
FTS *fts;
|
||||
FTSENT *node;
|
||||
};
|
||||
|
||||
enum b_status b_directory_open(
|
||||
struct b_directory *root, const char *path, struct b_directory **out)
|
||||
{
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
int b_directory_iterator_begin(
|
||||
struct b_directory *directory, struct b_directory_iterator *it)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool b_directory_iterator_next(struct b_directory_iterator *it)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
enum b_status b_directory_iterator_erase(struct b_directory_iterator *it)
|
||||
{
|
||||
return B_SUCCESS;
|
||||
}
|
||||
|
||||
bool b_directory_iterator_is_valid(const struct b_directory_iterator *it)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
0
io/sys/darwin/path.c
Normal file
0
io/sys/darwin/path.c
Normal file
Reference in New Issue
Block a user