From 30a01a66162b5fa7c3c3461d6a4edda3d422dc56 Mon Sep 17 00:00:00 2001 From: jozan Date: Sat, 14 Nov 2020 16:51:43 +0000 Subject: Now renames BE CAREFUL FossilOrigin-Name: e18d5bfe3152d94caeea60a9e78371e51f7eb3c04832e2f3f2b4c09baf3f7734 --- src/c_unixize.c | 21 ++++++++++++++++++--- 1 file 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); } /* -- cgit v1.2.3