io: path: add b_path_duplicate()

This commit is contained in:
2025-07-28 22:18:52 +01:00
parent 15ae12aa2e
commit 8554541f3a
2 changed files with 18 additions and 1 deletions

View File

@@ -120,6 +120,22 @@ struct b_path *b_path_create_from_cstr(const char *cstr)
return path;
}
struct b_path *b_path_duplicate(const struct b_path *path)
{
struct b_path *new_path = b_path_create();
if (!path) {
return NULL;
}
new_path->pathstr = b_string_duplicate(path->pathstr);
if (!new_path->pathstr) {
b_path_release(new_path);
return NULL;
}
return new_path;
}
static void append_path(struct b_path *dest, const struct b_path *src)
{
if (b_path_is_absolute(src)) {