From 13c5117fbbdc700de41b29dd7e59a7478a8d0748 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Sat, 20 Apr 2002 20:54:38 +0000 Subject: [PATCH] - Fixed move and copy when no destination supplied (assumes '.' now as per windows) - Fixed move so uses full path name for destination file, and if destination is a directory, uses original filename. --- programs/wcmd/builtins.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/programs/wcmd/builtins.c b/programs/wcmd/builtins.c index d9504b919fe..9b188380150 100644 --- a/programs/wcmd/builtins.c +++ b/programs/wcmd/builtins.c @@ -93,6 +93,12 @@ char string[8], outpath[MAX_PATH], inpath[MAX_PATH], *infile; WCMD_output ("Wildcards not yet supported\n"); return; } + + /* If no destination supplied, assume current directory */ + if (param2[0] == 0x00) { + strcpy(param2, "."); + } + GetFullPathName (param2, sizeof(outpath), outpath, NULL); hff = FindFirstFile (outpath, &fd); if (hff != INVALID_HANDLE_VALUE) { @@ -103,6 +109,7 @@ char string[8], outpath[MAX_PATH], inpath[MAX_PATH], *infile; } FindClose (hff); } + force = (strstr (quals, "/Y") != NULL); if (!force) { hff = FindFirstFile (outpath, &fd); @@ -402,12 +409,33 @@ char condition[MAX_PATH], *command, *s; void WCMD_move () { int status; +char outpath[MAX_PATH], inpath[MAX_PATH], *infile; +WIN32_FIND_DATA fd; +HANDLE hff; if ((strchr(param1,'*') != NULL) || (strchr(param1,'%') != NULL)) { WCMD_output ("Wildcards not yet supported\n"); return; -} - status = MoveFile (param1, param2); + } + + /* If no destination supplied, assume current directory */ + if (param2[0] == 0x00) { + strcpy(param2, "."); + } + + /* If 2nd parm is directory, then use original filename */ + GetFullPathName (param2, sizeof(outpath), outpath, NULL); + hff = FindFirstFile (outpath, &fd); + if (hff != INVALID_HANDLE_VALUE) { + if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + GetFullPathName (param1, sizeof(inpath), inpath, &infile); + strcat (outpath, "\\"); + strcat (outpath, infile); + } + FindClose (hff); + } + + status = MoveFile (param1, outpath); if (!status) WCMD_print_error (); }