io: store current directory iterator filepath as a b_path
This commit is contained in:
@@ -153,8 +153,23 @@ static void cleanup_iterator(struct b_directory_iterator *it)
|
||||
|
||||
static void update_iterator_data(struct b_directory_iterator *it)
|
||||
{
|
||||
if (it->filepath) {
|
||||
b_path_release(B_PATH(it->filepath));
|
||||
it->filepath = NULL;
|
||||
}
|
||||
|
||||
struct iteration_state *state = get_iteration_state(it->_z);
|
||||
it->filename = state->data.cFileName;
|
||||
|
||||
struct b_path *filename = b_path_create_from_cstr(it->filename);
|
||||
|
||||
const struct b_path *parts[] = {
|
||||
state->search_path,
|
||||
filename,
|
||||
};
|
||||
|
||||
it->filepath
|
||||
= b_path_join(parts, sizeof parts / sizeof parts[0]);
|
||||
}
|
||||
|
||||
static bool move_into_directory(struct b_directory_iterator *it, const char *dir_name)
|
||||
|
||||
@@ -166,14 +166,17 @@ struct b_path *b_path_join(
|
||||
|
||||
struct b_path *b_path_make_absolute(const struct b_path *in)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_path *b_path_make_relative(const struct b_path *in)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct b_path *b_path_make_canonical(const struct b_path *in)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool b_path_is_absolute(const struct b_path *path)
|
||||
@@ -202,17 +205,28 @@ bool b_path_is_absolute(const struct b_path *path)
|
||||
|
||||
bool b_path_exists(const struct b_path *path)
|
||||
{
|
||||
|
||||
DWORD attrib = GetFileAttributesA(b_path_ptr(path));
|
||||
return attrib != INVALID_FILE_ATTRIBUTES;
|
||||
}
|
||||
|
||||
bool b_path_is_file(const struct b_path *path)
|
||||
{
|
||||
DWORD attrib = GetFileAttributesA(b_path_ptr(path));
|
||||
if (attrib == INVALID_FILE_ATTRIBUTES) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (attrib & FILE_ATTRIBUTE_NORMAL) != 0;
|
||||
}
|
||||
|
||||
bool b_path_is_directory(const struct b_path *path)
|
||||
{
|
||||
DWORD attrib = GetFileAttributesA(b_path_ptr(path));
|
||||
if (attrib == INVALID_FILE_ATTRIBUTES) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
const char *b_path_ptr(const struct b_path *path)
|
||||
@@ -220,17 +234,10 @@ const char *b_path_ptr(const struct b_path *path)
|
||||
return b_string_ptr(path->pathstr);
|
||||
}
|
||||
|
||||
struct b_path *b_path_retain(struct b_path *path)
|
||||
{
|
||||
}
|
||||
|
||||
void b_path_release(struct b_path *path)
|
||||
{
|
||||
}
|
||||
|
||||
void path_release(struct b_object* obj)
|
||||
{
|
||||
b_path_release((struct b_path *)obj);
|
||||
struct b_path *path = B_PATH(obj);
|
||||
b_string_release(path->pathstr);
|
||||
}
|
||||
|
||||
void path_to_string(struct b_object* obj, struct b_stringstream* out)
|
||||
|
||||
Reference in New Issue
Block a user