diff options
Diffstat (limited to 'cp_mv.c')
-rw-r--r-- | cp_mv.c | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -130,8 +130,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
130 | if (mv_Action_first_time && (dz_i == is_mv)) { | 130 | if (mv_Action_first_time && (dz_i == is_mv)) { |
131 | mv_Action_first_time = errno = 0; | 131 | mv_Action_first_time = errno = 0; |
132 | if (rename(fileName, destName) < 0 && errno != EXDEV) { | 132 | if (rename(fileName, destName) < 0 && errno != EXDEV) { |
133 | error_msg("rename(%s, %s): %s\n", fileName, destName, | 133 | perror_msg("rename(%s, %s)", fileName, destName); |
134 | strerror(errno)); | ||
135 | goto do_copyFile; /* Try anyway... */ | 134 | goto do_copyFile; /* Try anyway... */ |
136 | } | 135 | } |
137 | else if (errno == EXDEV) | 136 | else if (errno == EXDEV) |
@@ -143,7 +142,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
143 | if (preserveFlag == TRUE && statbuf->st_nlink > 1) { | 142 | if (preserveFlag == TRUE && statbuf->st_nlink > 1) { |
144 | if (is_in_ino_dev_hashtable(statbuf, &name)) { | 143 | if (is_in_ino_dev_hashtable(statbuf, &name)) { |
145 | if (link(name, destName) < 0) { | 144 | if (link(name, destName) < 0) { |
146 | error_msg("link(%s, %s): %s\n", name, destName, strerror(errno)); | 145 | perror_msg("link(%s, %s)", name, destName); |
147 | return FALSE; | 146 | return FALSE; |
148 | } | 147 | } |
149 | return TRUE; | 148 | return TRUE; |
@@ -162,11 +161,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
162 | 161 | ||
163 | if (S_ISDIR(statbuf->st_mode)) { | 162 | if (S_ISDIR(statbuf->st_mode)) { |
164 | if (rmdir(fileName) < 0) { | 163 | if (rmdir(fileName) < 0) { |
165 | error_msg("rmdir(%s): %s\n", fileName, strerror(errno)); | 164 | perror_msg("rmdir(%s)", fileName); |
166 | status = FALSE; | 165 | status = FALSE; |
167 | } | 166 | } |
168 | } else if (unlink(fileName) < 0) { | 167 | } else if (unlink(fileName) < 0) { |
169 | error_msg("unlink(%s): %s\n", fileName, strerror(errno)); | 168 | perror_msg("unlink(%s)", fileName); |
170 | status = FALSE; | 169 | status = FALSE; |
171 | } | 170 | } |
172 | return status; | 171 | return status; |
@@ -260,20 +259,20 @@ extern int cp_mv_main(int argc, char **argv) | |||
260 | char *pushd, *d, *p; | 259 | char *pushd, *d, *p; |
261 | 260 | ||
262 | if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { | 261 | if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { |
263 | error_msg("getcwd(): %s\n", strerror(errno)); | 262 | perror_msg("getcwd()"); |
264 | continue; | 263 | continue; |
265 | } | 264 | } |
266 | if (chdir(baseDestName) < 0) { | 265 | if (chdir(baseDestName) < 0) { |
267 | error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno)); | 266 | perror_msg("chdir(%s)", baseSrcName); |
268 | continue; | 267 | continue; |
269 | } | 268 | } |
270 | if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { | 269 | if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { |
271 | error_msg("getcwd(): %s\n", strerror(errno)); | 270 | perror_msg("getcwd()"); |
272 | continue; | 271 | continue; |
273 | } | 272 | } |
274 | while (!state && *d != '\0') { | 273 | while (!state && *d != '\0') { |
275 | if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ | 274 | if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ |
276 | error_msg("stat(%s): %s\n", d, strerror(errno)); | 275 | perror_msg("stat(%s)", d); |
277 | state = -1; | 276 | state = -1; |
278 | continue; | 277 | continue; |
279 | } | 278 | } |
@@ -290,7 +289,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
290 | } | 289 | } |
291 | } | 290 | } |
292 | if (chdir(pushd) < 0) { | 291 | if (chdir(pushd) < 0) { |
293 | error_msg("chdir(%s): %s\n", pushd, strerror(errno)); | 292 | perror_msg("chdir(%s)", pushd); |
294 | free(pushd); | 293 | free(pushd); |
295 | free(d); | 294 | free(d); |
296 | continue; | 295 | continue; |