diff options
Diffstat (limited to 'mv.c')
-rw-r--r-- | mv.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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)); |