diff options
Diffstat (limited to 'utility.c')
-rw-r--r-- | utility.c | 28 |
1 files changed, 11 insertions, 17 deletions
@@ -58,9 +58,8 @@ int isDirectory(const char *name) | |||
58 | * be set.) | 58 | * be set.) |
59 | */ | 59 | */ |
60 | int | 60 | int |
61 | copyFile( | 61 | copyFile( const char *srcName, const char *destName, |
62 | const char *srcName, | 62 | int setModes, int followLinks) |
63 | const char *destName, int setModes, int followLinks) | ||
64 | { | 63 | { |
65 | int rfd; | 64 | int rfd; |
66 | int wfd; | 65 | int wfd; |
@@ -75,7 +74,6 @@ copyFile( | |||
75 | result = stat(srcName, &srcStatBuf); | 74 | result = stat(srcName, &srcStatBuf); |
76 | else | 75 | else |
77 | result = lstat(srcName, &srcStatBuf); | 76 | result = lstat(srcName, &srcStatBuf); |
78 | |||
79 | if (result < 0) { | 77 | if (result < 0) { |
80 | perror(srcName); | 78 | perror(srcName); |
81 | return FALSE; | 79 | return FALSE; |
@@ -115,7 +113,8 @@ copyFile( | |||
115 | return (FALSE); | 113 | return (FALSE); |
116 | } | 114 | } |
117 | link_val[link_size] = '\0'; | 115 | link_val[link_size] = '\0'; |
118 | if (symlink(link_val, destName)) { | 116 | link_size = symlink(link_val, destName); |
117 | if (link_size != 0) { | ||
119 | perror(destName); | 118 | perror(destName); |
120 | return (FALSE); | 119 | return (FALSE); |
121 | } | 120 | } |
@@ -179,7 +178,6 @@ copyFile( | |||
179 | 178 | ||
180 | 179 | ||
181 | error_exit: | 180 | error_exit: |
182 | //fprintf(stderr, "choking on %s\n", destName); | ||
183 | perror(destName); | 181 | perror(destName); |
184 | close(rfd); | 182 | close(rfd); |
185 | close(wfd); | 183 | close(wfd); |
@@ -476,10 +474,11 @@ recursiveAction(const char *fileName, int recurse, int followLinks, | |||
476 | struct stat statbuf; | 474 | struct stat statbuf; |
477 | struct dirent *next; | 475 | struct dirent *next; |
478 | 476 | ||
479 | if (followLinks) | 477 | if (followLinks == FALSE) |
480 | status = lstat(fileName, &statbuf); | ||
481 | else | ||
482 | status = stat(fileName, &statbuf); | 478 | status = stat(fileName, &statbuf); |
479 | else | ||
480 | status = lstat(fileName, &statbuf); | ||
481 | |||
483 | if (status < 0) { | 482 | if (status < 0) { |
484 | perror(fileName); | 483 | perror(fileName); |
485 | return (FALSE); | 484 | return (FALSE); |
@@ -487,16 +486,11 @@ recursiveAction(const char *fileName, int recurse, int followLinks, | |||
487 | 486 | ||
488 | if (recurse == FALSE) { | 487 | if (recurse == FALSE) { |
489 | if (S_ISDIR(statbuf.st_mode)) { | 488 | if (S_ISDIR(statbuf.st_mode)) { |
490 | if (dirAction == NULL) | 489 | if (dirAction != NULL) |
491 | return (TRUE); | ||
492 | else | ||
493 | return (dirAction(fileName)); | 490 | return (dirAction(fileName)); |
494 | } else { | ||
495 | if (fileAction == NULL) | ||
496 | return (TRUE); | ||
497 | else | 491 | else |
498 | return (fileAction(fileName)); | 492 | return (TRUE); |
499 | } | 493 | } |
500 | } | 494 | } |
501 | 495 | ||
502 | if (S_ISDIR(statbuf.st_mode)) { | 496 | if (S_ISDIR(statbuf.st_mode)) { |