diff options
author | jozan <jozan@noemail.net> | 2020-11-08 00:27:27 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-08 00:27:27 +0000 |
commit | 538efe3fc1e62a231fa10cd3071c2c7a69c7d281 (patch) | |
tree | a7ed803d4becaeea6a84b36def84952a9601e4da /src/u_utils.c | |
parent | Merging branch 'go-full-stack' into 'trunk' (diff) | |
download | unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.gz unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.bz2 unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.xz unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.tar.zst unixize-538efe3fc1e62a231fa10cd3071c2c7a69c7d281.zip |
Added relative path nice
FossilOrigin-Name: 9cca594d1c68d5b68ea84412f2d2809e337d6b9cd1d0b0ef034feec55a8c2ae0
Diffstat (limited to '')
-rw-r--r-- | src/u_utils.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/u_utils.c b/src/u_utils.c index e352eb6..65b59a3 100644 --- a/src/u_utils.c +++ b/src/u_utils.c @@ -43,6 +43,8 @@ * 2020-11-05 19:27 */ +#include <sys/param.h> + #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -177,3 +179,39 @@ u_get_nargv(struct opts_s* opts) } return (nargv); } + +void +u_increase_subpath +(char subp[], + const char newp[]) +{ + strlcpy( + subp + strlen(subp), + newp, + MAXPATHLEN - strlen(subp) - 1 + ); + subp[strlen(subp) + 1] = 0x00; + subp[strlen(subp)] = '/'; +} + +void +u_decrease_subpath(char subp[]) +{ + char* p; + + p = subp; + p += strlen(subp); + if (p == 0) { + return; + } + p -= 2; + while (subp - p != 0 && *p != '/') { + p--; + } + if (*p == '/') { + *(p + 1) = 0x00; + } + else if (subp - p == 0) { + *p = 0x00; + } +} |