diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-18 16:19:13 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-18 17:30:29 +0200 |
commit | 28f9bcd65a31487c9d624ded723fc7cd07af69c7 (patch) | |
tree | f2fdc1d18428e0e06f7416588722f0db368fc59a | |
parent | Merge pull request #24720 from yuwata/dissect-image-take-reference (diff) | |
download | systemd-28f9bcd65a31487c9d624ded723fc7cd07af69c7.tar.xz systemd-28f9bcd65a31487c9d624ded723fc7cd07af69c7.zip |
path-util: add examples for path_make_relative() and path_make_relative_parent()
Addresses https://github.com/systemd/systemd/pull/24646#discussion_r973691797.
-rw-r--r-- | src/basic/path-util.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 29a899b421..d8167da4f8 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -202,7 +202,17 @@ int path_make_relative_parent(const char *from_child, const char *to, char **ret assert(ret); /* Similar to path_make_relative(), but provides the relative path from the parent directory of - * 'from_child'. This may be useful when creating relative symlink. */ + * 'from_child'. This may be useful when creating relative symlink. + * + * E.g. + * - from = "/path/to/aaa", to = "/path/to/bbb" + * path_make_relative(from, to) = "../bbb" + * path_make_relative_parent(from, to) = "bbb" + * + * - from = "/path/to/aaa/bbb", to = "/path/to/ccc/ddd" + * path_make_relative(from, to) = "../../ccc/ddd" + * path_make_relative_parent(from, to) = "../ccc/ddd" + */ r = path_extract_directory(from_child, &from); if (r < 0) |