diff options
author | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-01-08 21:16:29 +0000 |
---|---|---|
committer | erik <erik@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2000-01-08 21:16:29 +0000 |
commit | 5b404e4297e9837f222fddd83e8739229971387b (patch) | |
tree | f86b3ad6f14114543da369473d0f4b20a4fdc436 /cp.c | |
parent | 1d0503f2c30407f59f11af786110adb4c68b07cf (diff) | |
download | busybox-w32-5b404e4297e9837f222fddd83e8739229971387b.tar.gz busybox-w32-5b404e4297e9837f222fddd83e8739229971387b.tar.bz2 busybox-w32-5b404e4297e9837f222fddd83e8739229971387b.zip |
Fix cp and mv so 'cp foo/README bar' where foo and bar are directories,
and README is a file.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@296 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'cp.c')
-rw-r--r-- | cp.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -48,6 +48,7 @@ static int srcDirFlag = FALSE; | |||
48 | static int fileAction(const char *fileName, struct stat* statbuf) | 48 | static int fileAction(const char *fileName, struct stat* statbuf) |
49 | { | 49 | { |
50 | char newdestName[NAME_MAX]; | 50 | char newdestName[NAME_MAX]; |
51 | char* newsrcName = NULL; | ||
51 | 52 | ||
52 | strcpy(newdestName, destName); | 53 | strcpy(newdestName, destName); |
53 | if ( srcDirFlag == TRUE ) { | 54 | if ( srcDirFlag == TRUE ) { |
@@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) | |||
62 | if (newdestName[strlen(newdestName)-1] != '/' ) { | 63 | if (newdestName[strlen(newdestName)-1] != '/' ) { |
63 | strcat(newdestName, "/"); | 64 | strcat(newdestName, "/"); |
64 | } | 65 | } |
65 | strcat(newdestName, srcName); | 66 | newsrcName = strrchr(srcName, '/'); |
67 | if (newsrcName && *newsrcName != '\0') | ||
68 | strcat(newdestName, newsrcName); | ||
69 | else | ||
70 | strcat(newdestName, srcName); | ||
66 | } | 71 | } |
67 | 72 | ||
68 | return (copyFile(fileName, newdestName, preserveFlag, followLinks)); | 73 | return (copyFile(fileName, newdestName, preserveFlag, followLinks)); |