util: remove path_get_parent(), in favour of dirname_malloc()
We don't need two functions that do essentialy the same, hence drop path_get_parent(), and stick to dirname_malloc(), but move it to path-util.[ch].
This commit is contained in:
parent
e4e73a6325
commit
5f311f8c0e
15 changed files with 62 additions and 108 deletions
|
@ -77,20 +77,6 @@ static void test_path(void) {
|
|||
assert_se(streq(basename("/aa///file..."), "file..."));
|
||||
assert_se(streq(basename("file.../"), ""));
|
||||
|
||||
#define test_parent(x, y) { \
|
||||
_cleanup_free_ char *z = NULL; \
|
||||
int r = path_get_parent(x, &z); \
|
||||
printf("expected: %s\n", y ? y : "error"); \
|
||||
printf("actual: %s\n", r<0 ? "error" : z); \
|
||||
assert_se((y==NULL) ^ (r==0)); \
|
||||
assert_se(y==NULL || path_equal(z, y)); \
|
||||
}
|
||||
|
||||
test_parent("./aa/bb/../file.da.", "./aa/bb/..");
|
||||
test_parent("/aa///.file", "/aa///");
|
||||
test_parent("/aa///file...", "/aa///");
|
||||
test_parent("file.../", NULL);
|
||||
|
||||
fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);
|
||||
assert_se(fd >= 0);
|
||||
assert_se(fd_is_mount_point(fd, "/", 0) > 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue