From 5b404e4297e9837f222fddd83e8739229971387b Mon Sep 17 00:00:00 2001 From: erik Date: Sat, 8 Jan 2000 21:16:29 +0000 Subject: 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 --- cp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cp.c') diff --git a/cp.c b/cp.c index 4af73c274..e96012d50 100644 --- a/cp.c +++ b/cp.c @@ -48,6 +48,7 @@ static int srcDirFlag = FALSE; static int fileAction(const char *fileName, struct stat* statbuf) { char newdestName[NAME_MAX]; + char* newsrcName = NULL; strcpy(newdestName, destName); if ( srcDirFlag == TRUE ) { @@ -62,7 +63,11 @@ static int fileAction(const char *fileName, struct stat* statbuf) if (newdestName[strlen(newdestName)-1] != '/' ) { strcat(newdestName, "/"); } - strcat(newdestName, srcName); + newsrcName = strrchr(srcName, '/'); + if (newsrcName && *newsrcName != '\0') + strcat(newdestName, newsrcName); + else + strcat(newdestName, srcName); } return (copyFile(fileName, newdestName, preserveFlag, followLinks)); -- cgit v1.2.3-55-g6feb