#ifndef BLUELIB_IO_PATH_H_ #define BLUELIB_IO_PATH_H_ #include #include #include #include #define B_PATH(p) ((b_path *)p) #define B_RV_PATH(cstr) B_PATH(B_RV(b_path_create_from_cstr(cstr))) struct b_file_info; typedef struct b_path b_path; BLUE_API b_path *b_path_create(); BLUE_API b_path *b_path_create_root(); BLUE_API b_path *b_path_create_cwd(); BLUE_API b_path *b_path_create_from_cstr(const char *path); BLUE_API b_path *b_path_duplicate(const b_path *path); BLUE_API b_path *b_path_join(const b_path *paths[], size_t nr_paths); BLUE_API b_path *b_path_make_absolute(const b_path *in); BLUE_API b_path *b_path_make_relative(const b_path *in); BLUE_API b_path *b_path_make_canonical(const b_path *in); BLUE_API bool b_path_is_absolute(const b_path *path); BLUE_API bool b_path_exists(const b_path *path); BLUE_API bool b_path_is_file(const b_path *path); BLUE_API bool b_path_is_directory(const b_path *path); BLUE_API b_status b_path_stat(const b_path *path, struct b_file_info *out); BLUE_API b_status b_path_unlink(const b_path *path); BLUE_API enum b_status b_path_get_directory( const b_path *path, b_path **out_dir_path); BLUE_API enum b_status b_path_get_filename( const b_path *path, struct b_string *out_name); BLUE_API const char *b_path_ptr(const b_path *path); BLUE_API size_t b_path_length(const b_path *path); static inline b_path *b_path_retain(b_path *path) { return B_PATH(b_retain(B_OBJECT(path))); } static inline void b_path_release(b_path *path) { b_release(B_OBJECT(path)); } #endif