87 lines
2.4 KiB
C
87 lines
2.4 KiB
C
#ifndef FX_IO_DIRECTORY_H_
|
|
#define FX_IO_DIRECTORY_H_
|
|
|
|
#include <fx/error.h>
|
|
#include <fx/io/file.h>
|
|
#include <fx/io/path.h>
|
|
#include <fx/iterator.h>
|
|
#include <fx/macros.h>
|
|
#include <fx/misc.h>
|
|
|
|
#define FX_DIRECTORY_ROOT ((fx_directory *)NULL)
|
|
|
|
FX_DECLS_BEGIN;
|
|
|
|
struct fx_directory_p;
|
|
|
|
#define FX_TYPE_DIRECTORY (fx_directory_get_type())
|
|
#define FX_TYPE_DIRECTORY_ITERATOR (fx_directory_iterator_get_type())
|
|
|
|
FX_DECLARE_TYPE(fx_directory);
|
|
FX_DECLARE_TYPE(fx_directory_iterator);
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_directory)
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_directory)
|
|
|
|
FX_TYPE_CLASS_DECLARATION_BEGIN(fx_directory_iterator)
|
|
FX_TYPE_CLASS_DECLARATION_END(fx_directory_iterator)
|
|
|
|
struct z__fx_directory_iterator;
|
|
|
|
typedef enum fx_directory_iterator_flags {
|
|
FX_DIRECTORY_ITERATE_PARENT_FIRST = 0x01u,
|
|
FX_DIRECTORY_ITERATE_PARENT_LAST = 0x02u,
|
|
} fx_directory_iterator_flags;
|
|
|
|
typedef enum fx_directory_open_flags {
|
|
FX_DIRECTORY_OPEN_CREATE = 0x01u,
|
|
FX_DIRECTORY_OPEN_CREATE_INTERMEDIATE = 0x03u,
|
|
FX_DIRECTORY_OPEN_DELETE_ON_CLOSE = 0x04u,
|
|
} fx_directory_open_flags;
|
|
|
|
typedef struct fx_directory_entry {
|
|
const fx_path *filepath;
|
|
char *filename;
|
|
fx_file_info info;
|
|
} fx_directory_entry;
|
|
|
|
FX_API fx_type fx_directory_get_type(void);
|
|
FX_API fx_type fx_directory_iterator_get_type(void);
|
|
|
|
FX_API fx_result fx_directory_open(
|
|
fx_directory *root,
|
|
const fx_path *path,
|
|
fx_directory_open_flags flags,
|
|
fx_directory **out);
|
|
FX_API fx_result fx_directory_open_temp(fx_directory **out);
|
|
FX_API const fx_path *fx_directory_get_path(const fx_directory *dir);
|
|
FX_API const fx_path *fx_directory_get_rel_path(const fx_directory *dir);
|
|
FX_API const char *fx_directory_get_path_cstr(const fx_directory *dir);
|
|
FX_API const char *fx_directory_get_rel_path_cstr(const fx_directory *dir);
|
|
FX_API fx_result fx_directory_delete(fx_directory *dir);
|
|
|
|
FX_API bool fx_directory_path_exists(
|
|
const fx_directory *root,
|
|
const fx_path *path);
|
|
FX_API bool fx_directory_path_is_file(
|
|
const fx_directory *root,
|
|
const fx_path *path);
|
|
FX_API bool fx_directory_path_is_directory(
|
|
const fx_directory *root,
|
|
const fx_path *path);
|
|
FX_API fx_result fx_directory_path_stat(
|
|
const fx_directory *root,
|
|
const fx_path *path,
|
|
struct fx_file_info *out);
|
|
FX_API fx_result fx_directory_path_unlink(
|
|
const fx_directory *root,
|
|
const fx_path *path);
|
|
|
|
FX_API fx_iterator *fx_directory_begin(
|
|
fx_directory *dir,
|
|
fx_directory_iterator_flags flags);
|
|
|
|
FX_DECLS_END;
|
|
|
|
#endif
|