diff options
Diffstat (limited to 'cp_mv.c')
-rw-r--r-- | cp_mv.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -75,7 +75,7 @@ static void name_too_long__exit (void) __attribute__((noreturn)); | |||
75 | static | 75 | static |
76 | void name_too_long__exit (void) | 76 | void name_too_long__exit (void) |
77 | { | 77 | { |
78 | fatalError(name_too_long); | 78 | error_msg_and_die(name_too_long); |
79 | } | 79 | } |
80 | 80 | ||
81 | static void | 81 | static void |
@@ -109,14 +109,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
109 | 109 | ||
110 | if (srcDirFlag == TRUE) { | 110 | if (srcDirFlag == TRUE) { |
111 | if (recursiveFlag == FALSE) { | 111 | if (recursiveFlag == FALSE) { |
112 | errorMsg(omitting_directory, baseSrcName); | 112 | error_msg(omitting_directory, baseSrcName); |
113 | return TRUE; | 113 | return TRUE; |
114 | } | 114 | } |
115 | srcBasename = (strstr(fileName, baseSrcName) | 115 | srcBasename = (strstr(fileName, baseSrcName) |
116 | + strlen(baseSrcName)); | 116 | + strlen(baseSrcName)); |
117 | 117 | ||
118 | if (destLen + strlen(srcBasename) > BUFSIZ) { | 118 | if (destLen + strlen(srcBasename) > BUFSIZ) { |
119 | errorMsg(name_too_long); | 119 | error_msg(name_too_long); |
120 | return FALSE; | 120 | return FALSE; |
121 | } | 121 | } |
122 | strcat(destName, srcBasename); | 122 | strcat(destName, srcBasename); |
@@ -130,7 +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 | errorMsg("rename(%s, %s): %s\n", fileName, destName, | 133 | error_msg("rename(%s, %s): %s\n", fileName, destName, |
134 | strerror(errno)); | 134 | strerror(errno)); |
135 | goto do_copyFile; /* Try anyway... */ | 135 | goto do_copyFile; /* Try anyway... */ |
136 | } | 136 | } |
@@ -143,7 +143,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
143 | if (preserveFlag == TRUE && statbuf->st_nlink > 1) { | 143 | if (preserveFlag == TRUE && statbuf->st_nlink > 1) { |
144 | if (is_in_ino_dev_hashtable(statbuf, &name)) { | 144 | if (is_in_ino_dev_hashtable(statbuf, &name)) { |
145 | if (link(name, destName) < 0) { | 145 | if (link(name, destName) < 0) { |
146 | errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno)); | 146 | error_msg("link(%s, %s): %s\n", name, destName, strerror(errno)); |
147 | return FALSE; | 147 | return FALSE; |
148 | } | 148 | } |
149 | return TRUE; | 149 | return TRUE; |
@@ -152,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
152 | add_to_ino_dev_hashtable(statbuf, destName); | 152 | add_to_ino_dev_hashtable(statbuf, destName); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag); | 155 | return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag); |
156 | } | 156 | } |
157 | 157 | ||
158 | static int | 158 | static int |
@@ -162,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk) | |||
162 | 162 | ||
163 | if (S_ISDIR(statbuf->st_mode)) { | 163 | if (S_ISDIR(statbuf->st_mode)) { |
164 | if (rmdir(fileName) < 0) { | 164 | if (rmdir(fileName) < 0) { |
165 | errorMsg("rmdir(%s): %s\n", fileName, strerror(errno)); | 165 | error_msg("rmdir(%s): %s\n", fileName, strerror(errno)); |
166 | status = FALSE; | 166 | status = FALSE; |
167 | } | 167 | } |
168 | } else if (unlink(fileName) < 0) { | 168 | } else if (unlink(fileName) < 0) { |
169 | errorMsg("unlink(%s): %s\n", fileName, strerror(errno)); | 169 | error_msg("unlink(%s): %s\n", fileName, strerror(errno)); |
170 | status = FALSE; | 170 | status = FALSE; |
171 | } | 171 | } |
172 | return status; | 172 | return status; |
@@ -224,7 +224,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
224 | 224 | ||
225 | 225 | ||
226 | if (strlen(argv[argc - 1]) > BUFSIZ) { | 226 | if (strlen(argv[argc - 1]) > BUFSIZ) { |
227 | errorMsg(name_too_long); | 227 | error_msg(name_too_long); |
228 | goto exit_false; | 228 | goto exit_false; |
229 | } | 229 | } |
230 | strcpy(baseDestName, argv[argc - 1]); | 230 | strcpy(baseDestName, argv[argc - 1]); |
@@ -232,9 +232,9 @@ extern int cp_mv_main(int argc, char **argv) | |||
232 | if (baseDestLen == 0) | 232 | if (baseDestLen == 0) |
233 | goto exit_false; | 233 | goto exit_false; |
234 | 234 | ||
235 | destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf); | 235 | destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf); |
236 | if (argc - optind > 2 && destDirFlag == FALSE) { | 236 | if (argc - optind > 2 && destDirFlag == FALSE) { |
237 | errorMsg(not_a_directory, baseDestName); | 237 | error_msg(not_a_directory, baseDestName); |
238 | goto exit_false; | 238 | goto exit_false; |
239 | } | 239 | } |
240 | 240 | ||
@@ -250,7 +250,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
250 | 250 | ||
251 | if (srcLen == 0) continue; /* "" */ | 251 | if (srcLen == 0) continue; /* "" */ |
252 | 252 | ||
253 | srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf); | 253 | srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf); |
254 | 254 | ||
255 | if ((flags_memo = (recursiveFlag == TRUE && | 255 | if ((flags_memo = (recursiveFlag == TRUE && |
256 | srcDirFlag == TRUE && destDirFlag == TRUE))) { | 256 | srcDirFlag == TRUE && destDirFlag == TRUE))) { |
@@ -260,26 +260,26 @@ extern int cp_mv_main(int argc, char **argv) | |||
260 | char *pushd, *d, *p; | 260 | char *pushd, *d, *p; |
261 | 261 | ||
262 | if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { | 262 | if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) { |
263 | errorMsg("getcwd(): %s\n", strerror(errno)); | 263 | error_msg("getcwd(): %s\n", strerror(errno)); |
264 | continue; | 264 | continue; |
265 | } | 265 | } |
266 | if (chdir(baseDestName) < 0) { | 266 | if (chdir(baseDestName) < 0) { |
267 | errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno)); | 267 | error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno)); |
268 | continue; | 268 | continue; |
269 | } | 269 | } |
270 | if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { | 270 | if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) { |
271 | errorMsg("getcwd(): %s\n", strerror(errno)); | 271 | error_msg("getcwd(): %s\n", strerror(errno)); |
272 | continue; | 272 | continue; |
273 | } | 273 | } |
274 | while (!state && *d != '\0') { | 274 | while (!state && *d != '\0') { |
275 | if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ | 275 | if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */ |
276 | errorMsg("stat(%s): %s\n", d, strerror(errno)); | 276 | error_msg("stat(%s): %s\n", d, strerror(errno)); |
277 | state = -1; | 277 | state = -1; |
278 | continue; | 278 | continue; |
279 | } | 279 | } |
280 | if ((sb.st_ino == srcStatBuf.st_ino) && | 280 | if ((sb.st_ino == srcStatBuf.st_ino) && |
281 | (sb.st_dev == srcStatBuf.st_dev)) { | 281 | (sb.st_dev == srcStatBuf.st_dev)) { |
282 | errorMsg("Cannot %s `%s' into a subdirectory of itself, " | 282 | error_msg("Cannot %s `%s' into a subdirectory of itself, " |
283 | "`%s/%s'\n", applet_name, baseSrcName, | 283 | "`%s/%s'\n", applet_name, baseSrcName, |
284 | baseDestName, baseSrcName); | 284 | baseDestName, baseSrcName); |
285 | state = -1; | 285 | state = -1; |
@@ -290,7 +290,7 @@ extern int cp_mv_main(int argc, char **argv) | |||
290 | } | 290 | } |
291 | } | 291 | } |
292 | if (chdir(pushd) < 0) { | 292 | if (chdir(pushd) < 0) { |
293 | errorMsg("chdir(%s): %s\n", pushd, strerror(errno)); | 293 | error_msg("chdir(%s): %s\n", pushd, strerror(errno)); |
294 | free(pushd); | 294 | free(pushd); |
295 | free(d); | 295 | free(d); |
296 | continue; | 296 | continue; |
@@ -305,11 +305,11 @@ extern int cp_mv_main(int argc, char **argv) | |||
305 | status = setjmp(catch); | 305 | status = setjmp(catch); |
306 | if (status == 0) { | 306 | if (status == 0) { |
307 | mv_Action_first_time = 1; | 307 | mv_Action_first_time = 1; |
308 | if (recursiveAction(baseSrcName, | 308 | if (recursive_action(baseSrcName, |
309 | recursiveFlag, followLinks, FALSE, | 309 | recursiveFlag, followLinks, FALSE, |
310 | cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false; | 310 | cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false; |
311 | if (dz_i == is_mv && | 311 | if (dz_i == is_mv && |
312 | recursiveAction(baseSrcName, | 312 | recursive_action(baseSrcName, |
313 | recursiveFlag, followLinks, TRUE, | 313 | recursiveFlag, followLinks, TRUE, |
314 | rm_Action, rm_Action, NULL) == FALSE) goto exit_false; | 314 | rm_Action, rm_Action, NULL) == FALSE) goto exit_false; |
315 | } | 315 | } |