diff options
author | Eric Andersen | 1999-10-17 05:43:39 +0000 |
---|---|---|
committer | Eric Andersen | 1999-10-17 05:43:39 +0000 |
commit | 9b5871888989b16f94cbba5dd304ac444def3afd (patch) | |
tree | 17187e3f6988830c0e329378e552995d083080ed /coreutils/cp.c | |
parent | cb6e25655f894c90e4befc4bee0e66794dd6858f (diff) | |
download | busybox-9b5871888989b16f94cbba5dd304ac444def3afd.zip busybox-9b5871888989b16f94cbba5dd304ac444def3afd.tar.gz |
Some fixes and such
Diffstat (limited to 'coreutils/cp.c')
-rw-r--r-- | coreutils/cp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/coreutils/cp.c b/coreutils/cp.c index 6ca66e6..4016fc7 100644 --- a/coreutils/cp.c +++ b/coreutils/cp.c @@ -41,21 +41,24 @@ static int preserveFlag = FALSE; static const char *srcName; static const char *destName; static const char *skipName; +static int dirFlag = FALSE; -static int fileAction(const char *fileName) +static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; strcpy(newdestName, destName); - strcat(newdestName, strstr(fileName, skipName)); + if (dirFlag==TRUE && newdestName[strlen(newdestName)-1]!= '/' ) { + strcat(newdestName, "/"); + if ( skipName != NULL) + strcat(newdestName, strstr(fileName, skipName)); + } return (copyFile(fileName, newdestName, preserveFlag, followLinks)); } extern int cp_main(int argc, char **argv) { - int dirFlag; - if (argc < 3) { fprintf(stderr, "Usage: %s", cp_usage); exit (FALSE); @@ -91,10 +94,9 @@ extern int cp_main(int argc, char **argv) destName = argv[argc - 1]; - dirFlag = isDirectory(destName); - if ((argc > 3) && !dirFlag) { + if ((argc > 3) && dirFlag==FALSE) { fprintf(stderr, "%s: not a directory\n", destName); exit (FALSE); } |