diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-01-08 21:16:29 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-01-08 21:16:29 +0000 |
commit | 1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032 (patch) | |
tree | f86b3ad6f14114543da369473d0f4b20a4fdc436 /coreutils/mv.c | |
parent | 5338ce19c873e7fc2a312eb0fd6443514b5cdb05 (diff) | |
download | busybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.tar.gz busybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.tar.bz2 busybox-w32-1dbc17f630fa92e2ee3ac0f1e2bccb6adf6f9032.zip |
Fix cp and mv so 'cp foo/README bar' where foo and bar are directories,
and README is a file.
-Erik
Diffstat (limited to 'coreutils/mv.c')
-rw-r--r-- | coreutils/mv.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c index 92c40c9b7..467a360de 100644 --- a/coreutils/mv.c +++ b/coreutils/mv.c | |||
@@ -40,6 +40,7 @@ static int srcDirFlag = FALSE; | |||
40 | static int fileAction(const char *fileName, struct stat* statbuf) | 40 | static int fileAction(const char *fileName, struct stat* statbuf) |
41 | { | 41 | { |
42 | char newdestName[NAME_MAX]; | 42 | char newdestName[NAME_MAX]; |
43 | char* newsrcName = NULL; | ||
43 | 44 | ||
44 | strcpy(newdestName, destName); | 45 | strcpy(newdestName, destName); |
45 | if ( srcDirFlag == TRUE ) { | 46 | if ( srcDirFlag == TRUE ) { |
@@ -50,7 +51,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) | |||
50 | if (newdestName[strlen(newdestName)-1] != '/' ) { | 51 | if (newdestName[strlen(newdestName)-1] != '/' ) { |
51 | strcat(newdestName, "/"); | 52 | strcat(newdestName, "/"); |
52 | } | 53 | } |
53 | strcat(newdestName, srcName); | 54 | newsrcName = strrchr(srcName, '/'); |
55 | if (newsrcName && *newsrcName != '\0') | ||
56 | strcat(newdestName, newsrcName); | ||
57 | else | ||
58 | strcat(newdestName, srcName); | ||
54 | } | 59 | } |
55 | 60 | ||
56 | return (copyFile(fileName, newdestName, TRUE, TRUE)); | 61 | return (copyFile(fileName, newdestName, TRUE, TRUE)); |