aboutsummaryrefslogtreecommitdiff
path: root/cp.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-17 05:43:39 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>1999-10-17 05:43:39 +0000
commitc45e09cde722eae8210c601491285aabd26307c3 (patch)
tree17187e3f6988830c0e329378e552995d083080ed /cp.c
parentc499de20c6b10ba483515e48aa61c4e5bb642f7c (diff)
downloadbusybox-w32-c45e09cde722eae8210c601491285aabd26307c3.tar.gz
busybox-w32-c45e09cde722eae8210c601491285aabd26307c3.tar.bz2
busybox-w32-c45e09cde722eae8210c601491285aabd26307c3.zip
Some fixes and such
git-svn-id: svn://busybox.net/trunk/busybox@29 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'cp.c')
-rw-r--r--cp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/cp.c b/cp.c
index 6ca66e642..4016fc760 100644
--- a/cp.c
+++ b/cp.c
@@ -41,21 +41,24 @@ static int preserveFlag = FALSE;
41static const char *srcName; 41static const char *srcName;
42static const char *destName; 42static const char *destName;
43static const char *skipName; 43static const char *skipName;
44static int dirFlag = FALSE;
44 45
45 46
46static int fileAction(const char *fileName) 47static int fileAction(const char *fileName, struct stat* statbuf)
47{ 48{
48 char newdestName[NAME_MAX]; 49 char newdestName[NAME_MAX];
49 strcpy(newdestName, destName); 50 strcpy(newdestName, destName);
50 strcat(newdestName, strstr(fileName, skipName)); 51 if (dirFlag==TRUE && newdestName[strlen(newdestName)-1]!= '/' ) {
52 strcat(newdestName, "/");
53 if ( skipName != NULL)
54 strcat(newdestName, strstr(fileName, skipName));
55 }
51 return (copyFile(fileName, newdestName, preserveFlag, followLinks)); 56 return (copyFile(fileName, newdestName, preserveFlag, followLinks));
52} 57}
53 58
54extern int cp_main(int argc, char **argv) 59extern int cp_main(int argc, char **argv)
55{ 60{
56 61
57 int dirFlag;
58
59 if (argc < 3) { 62 if (argc < 3) {
60 fprintf(stderr, "Usage: %s", cp_usage); 63 fprintf(stderr, "Usage: %s", cp_usage);
61 exit (FALSE); 64 exit (FALSE);
@@ -91,10 +94,9 @@ extern int cp_main(int argc, char **argv)
91 94
92 95
93 destName = argv[argc - 1]; 96 destName = argv[argc - 1];
94
95 dirFlag = isDirectory(destName); 97 dirFlag = isDirectory(destName);
96 98
97 if ((argc > 3) && !dirFlag) { 99 if ((argc > 3) && dirFlag==FALSE) {
98 fprintf(stderr, "%s: not a directory\n", destName); 100 fprintf(stderr, "%s: not a directory\n", destName);
99 exit (FALSE); 101 exit (FALSE);
100 } 102 }