]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: add examples for path_make_relative() and path_make_relative_parent()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 18 Sep 2022 14:19:13 +0000 (23:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 18 Sep 2022 15:30:29 +0000 (00:30 +0900)
Addresses https://github.com/systemd/systemd/pull/24646#discussion_r973691797.

src/basic/path-util.c

index 29a899b421d7a2e1e8c268abf3c4550775743d53..d8167da4f84e85048a458d847b13e34d8f6d2798 100644 (file)
@@ -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)