diff options
author | jozan <jozan@noemail.net> | 2020-11-14 16:51:43 +0000 |
---|---|---|
committer | jozan <jozan@noemail.net> | 2020-11-14 16:51:43 +0000 |
commit | 30a01a66162b5fa7c3c3461d6a4edda3d422dc56 (patch) | |
tree | dbb1c1c49b6bfc33e189356b814456f6ebd83a4d | |
parent | Recursive bug fix (diff) | |
download | unixize-30a01a66162b5fa7c3c3461d6a4edda3d422dc56.tar.gz unixize-30a01a66162b5fa7c3c3461d6a4edda3d422dc56.tar.bz2 unixize-30a01a66162b5fa7c3c3461d6a4edda3d422dc56.tar.xz unixize-30a01a66162b5fa7c3c3461d6a4edda3d422dc56.tar.zst unixize-30a01a66162b5fa7c3c3461d6a4edda3d422dc56.zip |
Now renames BE CAREFUL
FossilOrigin-Name: e18d5bfe3152d94caeea60a9e78371e51f7eb3c04832e2f3f2b4c09baf3f7734
-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 faee7ab..0f41bd3 100644 --- a/src/c_unixize.c +++ b/src/c_unixize.c @@ -73,6 +73,7 @@ main struct opts_s opts; int nargc; char** nargv; + static int ret = 0; static char subpath[MAXPATHLEN] = ""; setlocale(LC_ALL, ""); @@ -96,7 +97,12 @@ main if (og_files == NULL) { return (0); } - new_files = c_subst_filenames(og_files, opts.hyphen, opts.preserve, opts.cxx); + new_files = c_subst_filenames( + og_files, + opts.hyphen, + opts.preserve, + opts.cxx + ); if (new_files == NULL) { c_lfiles_clear(&og_files); return (1); @@ -147,7 +153,16 @@ main ); } if (opts.pretend == FALSE) { - /* rename(); */ + if (rename(og_files->filename, new_files->filename) == -1) { + dprintf( + STDERR_FILENO, + "unixize: rename %s to %s: %s\n", + og_files->filename, + new_files->filename, + strerror(errno) + ); + ret = 2; + } } } else if (opts.rverbose == TRUE) { @@ -163,7 +178,7 @@ main } c_lfiles_clear(&og_files_head); c_lfiles_clear(&new_files_head); - return (0); + return (ret); } /* |