INT cmd_path (LPTSTR param) { if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_PATH_HELP1); return 0; } nErrorLevel = 0; /* if param is empty, display the PATH environment variable */ if (!param || !*param) { DWORD dwBuffer; LPTSTR pszBuffer; pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE); if (dwBuffer == 0) { cmd_free(pszBuffer); ConOutResPrintf(STRING_VOL_HELP2, _T("PATH")); return 0; } else if (dwBuffer > ENV_BUFFER_SIZE) { pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR)); GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer); } ConOutPrintf (_T("PATH=%s\n"), pszBuffer); cmd_free (pszBuffer); return 0; } /* skip leading '=' */ if (*param == _T('=')) param++; /* set PATH environment variable */ if (!SetEnvironmentVariable (_T("PATH"), param)) { nErrorLevel = 1; return 1; } return 0; }
VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor) { /* Length of string before we complete it */ INT_PTR StartLength; /* Length of string after completed */ //INT EndLength; /* The number of chars added too it */ //static INT DiffLength = 0; /* Used to find and assemble the string that is returned */ TCHAR szBaseWord[MAX_PATH]; TCHAR szPrefix[MAX_PATH]; TCHAR szOriginal[MAX_PATH]; TCHAR szSearchPath[MAX_PATH]; /* Save the strings used last time, so if they hit tab again */ static TCHAR LastReturned[MAX_PATH]; static TCHAR LastSearch[MAX_PATH]; static TCHAR LastPrefix[MAX_PATH]; /* Used to search for files */ HANDLE hFile; WIN32_FIND_DATA file; /* List of all the files */ FileName * FileList = NULL; /* Number of files */ INT FileListSize = 0; /* Used for loops */ UINT i; /* Editable string of what was passed in */ TCHAR str[MAX_PATH]; /* Keeps track of what element was last selected */ static INT Sel; BOOL NeededQuote = FALSE; BOOL ShowAll = TRUE; TCHAR * line = strIN; strOut[0] = _T('\0'); while (_istspace (*line)) line++; if (!_tcsnicmp (line, _T("rd "), 3) || !_tcsnicmp (line, _T("cd "), 3)) ShowAll = FALSE; /* Copy the string, str can be edited and original should not be */ _tcscpy(str,strIN); _tcscpy(szOriginal,strIN); /* Look to see if the cusor is not at the end of the string */ if ((cusor + 1) < _tcslen(str)) str[cusor] = _T('\0'); /* Look to see if they hit tab again, if so cut off the diff length */ if (_tcscmp(str,LastReturned) || !_tcslen(str)) { /* We need to know how many chars we added from the start */ StartLength = _tcslen(str); /* no string, we need all files in that directory */ if (!StartLength) { _tcscat(str,_T("*")); } /* Zero it out first */ szBaseWord[0] = _T('\0'); szPrefix[0] = _T('\0'); /*What comes out of this needs to be: szBaseWord = path no quotes to the object szPrefix = what leads up to the filename no quote at the END of the full name */ FindPrefixAndSuffix(str,szPrefix,szBaseWord); /* Strip quotes */ for(i = 0; i < _tcslen(szBaseWord); ) { if (szBaseWord[i] == _T('\"')) memmove(&szBaseWord[i],&szBaseWord[i + 1], _tcslen(&szBaseWord[i]) * sizeof(TCHAR)); else i++; } /* clear it out */ memset(szSearchPath, 0, sizeof(szSearchPath)); /* Start the search for all the files */ GetFullPathName(szBaseWord, MAX_PATH, szSearchPath, NULL); /* Got a device path? Fallback to the the current dir plus the short path */ if (szSearchPath[0] == _T('\\') && szSearchPath[1] == _T('\\') && szSearchPath[2] == _T('.') && szSearchPath[3] == _T('\\')) { GetCurrentDirectory(MAX_PATH, szSearchPath); _tcscat(szSearchPath, _T("\\")); _tcscat(szSearchPath, szBaseWord); } if (StartLength > 0) { _tcscat(szSearchPath,_T("*")); } _tcscpy(LastSearch,szSearchPath); _tcscpy(LastPrefix,szPrefix); } else { _tcscpy(szSearchPath, LastSearch); _tcscpy(szPrefix, LastPrefix); StartLength = 0; } /* search for the files it might be */ hFile = FindFirstFile (szSearchPath, &file); if (hFile == INVALID_HANDLE_VALUE) { /* Assemble the original string and return */ _tcscpy(strOut,szOriginal); return; } /* assemble a list of all files names */ do { FileName * oldFileList = FileList; if (!_tcscmp (file.cFileName, _T(".")) || !_tcscmp (file.cFileName, _T(".."))) continue; /* Don't show files when they are doing 'cd' or 'rd' */ if (!ShowAll && file.dwFileAttributes != 0xFFFFFFFF && !(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { continue; } /* Add the file to the list of files */ FileList = cmd_realloc(FileList, ++FileListSize * sizeof(FileName)); if (FileList == NULL) { /* Don't leak old buffer */ cmd_free(oldFileList); /* Assemble the original string and return */ _tcscpy(strOut,szOriginal); FindClose(hFile); ConOutFormatMessage (GetLastError()); return; } /* Copies the file name into the struct */ _tcscpy(FileList[FileListSize-1].Name,file.cFileName); } while(FindNextFile(hFile,&file)); FindClose(hFile); /* Check the size of the list to see if we found any matches */ if (FileListSize == 0) { _tcscpy(strOut,szOriginal); if (FileList != NULL) cmd_free(FileList); return; } /* Sort the files */ qsort(FileList,FileListSize,sizeof(FileName), compare); /* Find the next/previous */ if (_tcslen(szOriginal) && !_tcscmp(szOriginal,LastReturned)) { if (bNext) { if (FileListSize - 1 == Sel) Sel = 0; else Sel++; } else { if (!Sel) Sel = FileListSize - 1; else Sel--; } } else { Sel = 0; } /* nothing found that matched last time so return the first thing in the list */ strOut[0] = _T('\0'); /* Special character in the name */ if (FileNameContainsSpecialCharacters(FileList[Sel].Name)) { INT LastSpace; BOOL bInside; /* It needs a " at the end */ NeededQuote = TRUE; LastSpace = -1; bInside = FALSE; /* Find the place to put the " at the start */ for(i = 0; i < _tcslen(szPrefix); i++) { if (szPrefix[i] == _T('\"')) bInside = !bInside; if (szPrefix[i] == _T(' ') && !bInside) LastSpace = i; } /* insert the quotation and move things around */ if (szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1) { memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) ); if ((UINT)(LastSpace + 1) == _tcslen(szPrefix)) { _tcscat(szPrefix,_T("\"")); } szPrefix[LastSpace + 1] = _T('\"'); } else if (LastSpace == -1) { /* Add quotation only if none exists already */ if (szPrefix[0] != _T('\"')) { _tcscpy(szBaseWord,_T("\"")); _tcscat(szBaseWord,szPrefix); _tcscpy(szPrefix,szBaseWord); } } } _tcscpy(strOut,szPrefix); _tcscat(strOut,FileList[Sel].Name); /* check for odd number of quotes means we need to close them */ if (!NeededQuote) { for(i = 0; i < _tcslen(strOut); i++) { if (strOut[i] == _T('\"')) NeededQuote = !NeededQuote; } } if (NeededQuote || (_tcslen(szPrefix) && szPrefix[_tcslen(szPrefix) - 1] == _T('\"'))) _tcscat(strOut,_T("\"")); _tcscpy(LastReturned,strOut); //EndLength = _tcslen(strOut); //DiffLength = EndLength - StartLength; if (FileList != NULL) cmd_free(FileList); }
BOOL SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) { static TCHAR pszDefaultPathExt[] = _T(".com;.exe;.bat;.cmd"); LPTSTR pszPathExt, pszPath; LPTSTR pCh; DWORD dwBuffer; TRACE ("SearchForExecutable: \'%s\'\n", debugstr_aw(pFileName)); /* load environment variable PATHEXT */ pszPathExt = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { LPTSTR pszOldPathExt = pszPathExt; pszPathExt = (LPTSTR)cmd_realloc (pszPathExt, dwBuffer * sizeof (TCHAR)); if (pszPathExt == NULL) { cmd_free(pszOldPathExt); return FALSE; } GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, dwBuffer); _tcslwr(pszPathExt); } else if (0 == dwBuffer) { _tcscpy(pszPathExt, pszDefaultPathExt); } else { _tcslwr(pszPathExt); } /* Check if valid directly on specified path */ if (SearchForExecutableSingle(pFileName, pFullName, pszPathExt, NULL)) { cmd_free(pszPathExt); return TRUE; } /* If an explicit directory was given, stop here - no need to search PATH. */ if (pFileName[1] == _T(':') || _tcschr(pFileName, _T('\\'))) { cmd_free(pszPathExt); return FALSE; } /* load environment variable PATH into buffer */ pszPath = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszPath, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { LPTSTR pszOldPath = pszPath; pszPath = (LPTSTR)cmd_realloc (pszPath, dwBuffer * sizeof (TCHAR)); if (pszPath == NULL) { cmd_free(pszOldPath); cmd_free(pszPathExt); return FALSE; } GetEnvironmentVariable (_T("PATH"), pszPath, dwBuffer); } TRACE ("SearchForExecutable(): Loaded PATH: %s\n", debugstr_aw(pszPath)); /* search in PATH */ pCh = _tcstok(pszPath, _T(";")); while (pCh) { if (SearchForExecutableSingle(pFileName, pFullName, pszPathExt, pCh)) { cmd_free(pszPath); cmd_free(pszPathExt); return TRUE; } pCh = _tcstok(NULL, _T(";")); } cmd_free(pszPath); cmd_free(pszPathExt); return FALSE; }
INT cmd_copy(LPTSTR param) { LPTSTR *arg; INT argc, i, nFiles, nOverwrite = 0, nSrc = -1, nDes = -1; /* this is the path up to the folder of the src and dest ie C:\windows\ */ TCHAR szDestPath[MAX_PATH]; TCHAR szSrcPath[MAX_PATH]; DWORD dwFlags = 0; /* If this is the type of copy where we are adding files */ BOOL bAppend = FALSE; WIN32_FIND_DATA findBuffer; HANDLE hFile = NULL; BOOL bTouch = FALSE; /* Used when something like "copy c*.exe d*.exe" during the process of figuring out the new name */ /* Pointer to keep track of how far through the append input(file1+file2+file3) we are */ TCHAR * appendPointer = _T("\0"); /* The full path to src and dest. This has drive letter, folders, and filename */ TCHAR tmpDestPath[MAX_PATH]; TCHAR tmpSrcPath[MAX_PATH]; /* A bool on weather or not the destination name will be taking from the input */ BOOL bSrcName = FALSE; /* Seems like a waste but it is a pointer used to copy from input to PreserveName */ TCHAR * UseThisName; /* for CMDCOPY env */ TCHAR *evar; int size; TCHAR * szTouch; BOOL bHasWildcard, bDone = FALSE, bMoreFiles = FALSE; BOOL bMultipleSource = FALSE, bMultipleDest = FALSE; /* Show help/usage info */ if (!_tcsncmp(param, _T("/?"), 2)) { ConOutResPaging(TRUE, STRING_COPY_HELP2); return 0; } nErrorLevel = 0; /* Get the envor value if it exists */ evar = cmd_alloc(512 * sizeof(TCHAR)); if (evar == NULL) size = 0; else size = GetEnvironmentVariable (_T("COPYCMD"), evar, 512); if (size > 512) { TCHAR *old_evar = evar; evar = cmd_realloc(evar,size * sizeof(TCHAR) ); if (evar!=NULL) size = GetEnvironmentVariable (_T("COPYCMD"), evar, size); else { size=0; evar = old_evar; } } /* check see if we did get any env variable */ if (size != 0) { int t = 0; /* scan and set the flags */ for (t = 0; t < size; t++) { if (_tcsncicmp(_T("/A"),&evar[t],2) == 0) { dwFlags |=COPY_ASCII; t++; } else if (_tcsncicmp(_T("/B"),&evar[t],2) == 0) { dwFlags |= COPY_BINARY; t++; } else if (_tcsncicmp(_T("/D"),&evar[t],2) == 0) { dwFlags |= COPY_DECRYPT; t++; } else if (_tcsncicmp(_T("/V"),&evar[t],2) == 0) { dwFlags |= COPY_VERIFY; t++; } else if (_tcsncicmp(_T("/N"),&evar[t],2) == 0) { dwFlags |= COPY_SHORTNAME; t++; } else if (_tcsncicmp(_T("/Y"),&evar[t],2) == 0) { dwFlags |= COPY_NO_PROMPT; t++; } else if (_tcsncicmp(_T("/-Y"),&evar[t],3) == 0) { dwFlags |= COPY_PROMPT; t+=2; } else if (_tcsncicmp(_T("/Z"),&evar[t],2) == 0) { dwFlags |= COPY_PROMPT; t++; } } } cmd_free(evar); /* Split the user input into array */ arg = split(param, &argc, FALSE, TRUE); nFiles = argc; /* Read switches and count files */ for (i = 0; i < argc; i++) { if (*arg[i] == _T('/')) { if (_tcslen(arg[i]) >= 2) { switch (_totupper(arg[i][1])) { case _T('A'): dwFlags |= COPY_ASCII; break; case _T('B'): dwFlags |= COPY_BINARY; break; case _T('D'): dwFlags |= COPY_DECRYPT; break; case _T('V'): dwFlags |= COPY_VERIFY; break; case _T('N'): dwFlags |= COPY_SHORTNAME; break; case _T('Y'): dwFlags |= COPY_NO_PROMPT; dwFlags &= ~COPY_PROMPT; break; case _T('-'): if (_tcslen(arg[i]) >= 3) if (_totupper(arg[i][2]) == _T('Y')) { dwFlags &= ~COPY_NO_PROMPT; dwFlags |= COPY_PROMPT; } break; case _T('Z'): dwFlags |= COPY_RESTART; break; default: /* Invalid switch */ ConOutResPrintf(STRING_ERROR_INVALID_SWITCH, _totupper(arg[i][1])); nErrorLevel = 1; freep (arg); return 1; break; } } /* If it was a switch, subtract from total arguments */ nFiles--; } else { /* If it isn't a switch then it is the source or destination */ if (nSrc == -1) { nSrc = i; } else if (*arg[i] == _T('+')) { /* Next file should be appended */ bMoreFiles = TRUE; nFiles -= 1; } else if (bMoreFiles) { /* Add this file to the source string this way we can do all checks directly on source string later on */ TCHAR * ptr; int length = (_tcslen(arg[nSrc]) + _tcslen(arg[i]) + 2) * sizeof(TCHAR); ptr = cmd_alloc(length); if (ptr) { _tcscpy(ptr, arg[nSrc]); _tcscat(ptr, _T("|")); _tcscat(ptr, arg[i]); cmd_free(arg[nSrc]); arg[nSrc] = ptr; nFiles -= 1; } bMoreFiles = FALSE; } else if (nDes == -1) { nDes = i; } } } /* keep quiet within batch files */ if (bc != NULL) { dwFlags |= COPY_NO_PROMPT; dwFlags &= ~COPY_PROMPT; } if (nFiles < 1) { /* There are not enough files, there has to be at least 1 */ ConOutResPuts(STRING_ERROR_REQ_PARAM_MISSING); freep(arg); return 1; } if (nFiles > 2) { /* There are too many file names in command */ ConErrResPrintf(STRING_ERROR_TOO_MANY_PARAMETERS,_T("")); nErrorLevel = 1; freep(arg); return 1; } if ((_tcschr(arg[nSrc], _T('|')) != NULL) || (_tcschr(arg[nSrc], _T('*')) != NULL) || (_tcschr(arg[nSrc], _T('?')) != NULL) || IsExistingDirectory(arg[nSrc])) { bMultipleSource = TRUE; } /* Reusing the number of files variable */ nFiles = 0; /* Check if no destination argument is passed */ if (nDes == -1) { /* If no destination was entered then just use the current directory as the destination */ GetCurrentDirectory(MAX_PATH, szDestPath); } else { /* Check if the destination is 'x:' */ if ((arg[nDes][1] == _T(':')) && (arg[nDes][2] == _T('\0'))) { GetRootPath(arg[nDes], szDestPath, MAX_PATH); } else { /* If the user entered two file names then form the full string path */ GetFullPathName(arg[nDes], MAX_PATH, szDestPath, NULL); } /* Make sure there is an ending slash to the path if the dest is a folder */ if ((_tcschr(szDestPath, _T('*')) == NULL) && IsExistingDirectory(szDestPath)) { bMultipleDest = TRUE; if (szDestPath[_tcslen(szDestPath) - 1] != _T('\\')) _tcscat(szDestPath, _T("\\")); } /* Check if the destination uses wildcards */ if ((_tcschr(arg[nDes], _T('*')) != NULL) || (_tcschr(arg[nDes], _T('?')) != NULL)) { bMultipleDest = TRUE; } } if (nDes != -1) /* you can only append files when there is a destination */ { if (bMultipleSource && !bMultipleDest) { /* We have multiple source files, but not multiple destination files. This means we are appending the soruce files. */ bAppend = TRUE; if (_tcschr(arg[nSrc], _T('|')) != NULL) appendPointer = arg[nSrc]; } } /* Save the name the user entered */ UseThisName = _tcsrchr(szDestPath,_T('\\')); if (UseThisName) { /* Split the name from the path */ *UseThisName++ = _T('\0'); /* Check if the dest path ends with '\*' or '\' */ if (((UseThisName[0] == _T('*')) && (UseThisName[1] == _T('\0'))) || (UseThisName[0] == _T('\0'))) { /* In this case we will be using the same name as the source file for the destination file because destination is a folder */ bSrcName = TRUE; UseThisName = NULL; } } else { /* Something's seriously wrong! */ UseThisName = szDestPath; } do { /* Get the full string of the path to the source file */ if (_tcschr(arg[nSrc], _T('|')) != NULL) { /* Reset the source path */ szSrcPath[0] = _T('\0'); /* Loop through the source file name and copy all the chars one at a time until it gets too + */ while(TRUE) { if (appendPointer[0] == _T('|')) { /* Skip the | and go to the next file name */ appendPointer++; break; } else if (appendPointer[0] == _T('\0')) { bDone = TRUE; break; } _tcsncat(szSrcPath, appendPointer, 1); appendPointer++; } if (_tcschr(arg[nSrc], _T(',')) != NULL) { /* Only time there is a , in the source is when they are using touch Cant have a destination and can only have on ,, at the end of the string Cant have more then one file name */ szTouch = _tcsstr(arg[nSrc], _T("|")); if (_tcsncmp(szTouch,_T("|,,\0"), 4) || (nDes != -1)) { ConErrResPrintf(STRING_ERROR_INVALID_PARAM_FORMAT,arg[nSrc]); nErrorLevel = 1; freep (arg); return 1; } bTouch = TRUE; bDone = TRUE; } } else { bDone = TRUE; _tcscpy(szSrcPath, arg[nSrc]); } /* "x:" is not a valid source path format. */ if ((szSrcPath[1] == _T(':')) && (szSrcPath[2] == _T('\0'))) { ConOutPrintf(_T("%s\n"), szSrcPath); ConOutFormatMessage(ERROR_FILE_NOT_FOUND, szSrcPath); nErrorLevel = 1; break; } /* From this point on, we can assume that the shortest path is 3 letters long and that would be [DriveLetter]:\ */ /* Check if the path has a wildcard */ bHasWildcard = (_tcschr(szSrcPath, _T('*')) != NULL); /* If there is no * in the path name and it is a folder then we will need to add a wildcard to the pathname so FindFirstFile comes up with all the files in that folder */ if (!bHasWildcard && IsExistingDirectory(szSrcPath)) { /* If it doesnt have a \ at the end already then on needs to be added */ if (szSrcPath[_tcslen(szSrcPath) - 1] != _T('\\')) _tcscat(szSrcPath, _T("\\")); _tcscat(szSrcPath, _T("*")); bHasWildcard = TRUE; } /* If the path ends with '\' add a wildcard at the end */ if (szSrcPath[_tcslen(szSrcPath) - 1] == _T('\\')) { _tcscat(szSrcPath, _T("*")); bHasWildcard = TRUE; } /* Get a list of all the files */ hFile = FindFirstFile(szSrcPath, &findBuffer); /* If it couldnt open the file handle, print out the error */ if (hFile == INVALID_HANDLE_VALUE) { /* only print source name when more then one file */ if (bMultipleSource) ConOutPrintf(_T("%s\n"), szSrcPath); ConOutFormatMessage(GetLastError(), szSrcPath); freep(arg); nErrorLevel = 1; return 1; } /* Strip the paths back to the folder they are in */ for (i = (_tcslen(szSrcPath) - 1); i > -1; i--) if (szSrcPath[i] != _T('\\')) szSrcPath[i] = _T('\0'); else break; do { /* Check Breaker */ if (CheckCtrlBreak(BREAK_INPUT)) { FindClose(hFile); freep(arg); return 1; } /* Set the override to yes each new file */ nOverwrite = 1; /* Ignore the . and .. files */ if (!_tcscmp(findBuffer.cFileName, _T(".")) || !_tcscmp(findBuffer.cFileName, _T("..")) || findBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { continue; } /* Copy the base folder over to a tmp string */ _tcscpy(tmpDestPath, szDestPath); _tcscat(tmpDestPath, _T("\\")); /* Can't put a file into a folder that isn't there */ if (_tcscmp(tmpDestPath, _T("\\\\.\\")) && !IsExistingDirectory(tmpDestPath)) { FindClose(hFile); ConOutFormatMessage(GetLastError(), szSrcPath); freep(arg); nErrorLevel = 1; return 1; } /* Copy over the destination path name */ if (bSrcName) _tcscat(tmpDestPath, findBuffer.cFileName); else { /* If there is no wildcard you can use the name the user entered */ if ((_tcschr(UseThisName, _T('*')) == NULL) && (_tcschr(UseThisName, _T('?')) == NULL)) { _tcscat(tmpDestPath, UseThisName); } else { TCHAR DoneFile[MAX_PATH]; BuildFileName(findBuffer.cFileName, UseThisName, DoneFile); /* Add the filename to the tmp string path */ _tcscat(tmpDestPath, DoneFile); } } /* Build the string path to the source file */ _tcscpy(tmpSrcPath,szSrcPath); _tcscat (tmpSrcPath, findBuffer.cFileName); /* Check to see if the file is the same file */ if (!bTouch && !_tcscmp(tmpSrcPath, tmpDestPath)) { ConOutResPrintf(STRING_COPY_ERROR2); nErrorLevel = 1; break; } /* only print source name when more then one file */ if (bMultipleSource) ConOutPrintf(_T("%s\n"), tmpSrcPath); /* Handle any overriding / prompting that needs to be done */ if (((!(dwFlags & COPY_NO_PROMPT) && IsExistingFile (tmpDestPath)) || dwFlags & COPY_PROMPT) && !bTouch) nOverwrite = CopyOverwrite(tmpDestPath); if (nOverwrite == PROMPT_NO || nOverwrite == PROMPT_BREAK) continue; if (nOverwrite == PROMPT_ALL || (nOverwrite == PROMPT_YES && bAppend)) dwFlags |= COPY_NO_PROMPT; /* Tell weather the copy was successful or not */ if (copy(tmpSrcPath,tmpDestPath, bAppend, dwFlags, bTouch)) { nFiles++; //LoadString(CMD_ModuleHandle, STRING_MOVE_ERROR1, szMsg, RC_STRING_MAX_SIZE); } else { /* print out the error message */ ConOutResPrintf(STRING_COPY_ERROR3); ConOutFormatMessage (GetLastError(), szSrcPath); nErrorLevel = 1; } /* Loop through all wildcard files */ } while (FindNextFile(hFile, &findBuffer)); /* Loop through all files in src string with a + */ } while(!bDone); /* print out the number of files copied */ ConOutResPrintf(STRING_COPY_FILE, bAppend ? 1 : nFiles); if (hFile) FindClose(hFile); if (arg != NULL) freep(arg); return 0; }