]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-path-util.c
path-util: rework file_in_same_dir() on top of path_extract_directory()
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Jan 2023 15:34:07 +0000 (16:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 24 Jan 2023 17:13:27 +0000 (18:13 +0100)
commit162f6477c60bf53da242276dee1efe03c686c9f3
treeac0bd8c16e7b193e5e834e8ea3c7104f5c552efa
parent5b532e14e3ac1d8f8cef90fd8c5b1ce277458ae7
path-util: rework file_in_same_dir() on top of path_extract_directory()

Let's port one more over.

Note that this changes behaviour of file_in_same_dir() in some regards.
Specifically, a trailing slash of the input path will be treated
differently: previously we'd operate below that dir then, instead of the
parent. I think that makes little sense however, and I think the code
using this function doesn't expect that either.

Moroever, addresses some corner cases if the path is specified as "/" or
".", i.e. where e cannot extract a parent. These will now be treated as
error, which I think is much cleaner.
src/basic/fs-util.c
src/basic/path-util.c
src/basic/path-util.h
src/nspawn/nspawn.c
src/shared/discover-image.c
src/test/test-path-util.c