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/c_unixize.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/c_unixize.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/c_unixize.c b/src/c_unixize.c index e08141b..15bfccf 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -71,7 +71,7 @@ main struct opts_s opts; int nargc; char** nargv; - /* static char subpath[MAXPATHLEN]; */ + static char subpath[MAXPATHLEN] = ""; if (c_get_opts(&opts, argc, argv) == FALSE) { return (0); @@ -80,6 +80,15 @@ main u_dump_errno_path(opts.dir); return (1); } + if ( + argv[0][0] != 'r' && + strlen(opts.dir) > 1 && + strncmp(opts.dir, ".", 2 * sizeof(char)) != 0 + ) { + strlcpy(subpath, opts.dir, MAXPATHLEN - 1); + subpath[strlen(subpath) + 1] = 0x00; + subpath[strlen(subpath)] = '/'; + } og_files = c_lfiles_gather(); if (og_files == NULL) { return (0); @@ -103,6 +112,7 @@ main u_dump_errno_path(og_files->filename); } else { + u_increase_subpath(subpath, og_files->filename); nargv = u_get_nargv(&opts); if (nargv != NULL) { nargc = 0; @@ -113,17 +123,22 @@ main u_del_nargv(nargv); } chdir("../"); + u_decrease_subpath(subpath); } } if (opts.verbose == TRUE) { dprintf( STDOUT_FILENO, - "'%s' -> '%s'\n", + "'%s%s' -> '%s%s'\n", + subpath, og_files->filename, + subpath, new_files->filename ); } - /* rename(); */ + if (opts.pretend == FALSE) { + /* rename(); */ + } og_files = og_files->next; new_files = new_files->next; } |