diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 1999-10-17 05:43:39 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 1999-10-17 05:43:39 +0000 |
commit | c45e09cde722eae8210c601491285aabd26307c3 (patch) | |
tree | 17187e3f6988830c0e329378e552995d083080ed /cp.c | |
parent | c499de20c6b10ba483515e48aa61c4e5bb642f7c (diff) | |
download | busybox-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.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -41,21 +41,24 @@ static int preserveFlag = FALSE; | |||
41 | static const char *srcName; | 41 | static const char *srcName; |
42 | static const char *destName; | 42 | static const char *destName; |
43 | static const char *skipName; | 43 | static const char *skipName; |
44 | static int dirFlag = FALSE; | ||
44 | 45 | ||
45 | 46 | ||
46 | static int fileAction(const char *fileName) | 47 | static 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 | ||
54 | extern int cp_main(int argc, char **argv) | 59 | extern 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 | } |