| 10504 | /////////////////////////////////////////////////////////////////////////////// |
| 10505 | |
| 10506 | int Line::Util_CopyFile(const char *szInputSource, const char *szInputDest, bool bOverwrite, bool bMove) |
| 10507 | { |
| 10508 | WIN32_FIND_DATA findData; |
| 10509 | HANDLE hSearch; |
| 10510 | bool bLoop; |
| 10511 | bool bFound = false; // Not found initially |
| 10512 | BOOL bRes; |
| 10513 | |
| 10514 | char szSource[_MAX_PATH+1]; |
| 10515 | char szDest[_MAX_PATH+1]; |
| 10516 | char szExpandedDest[MAX_PATH+1]; |
| 10517 | char szTempPath[_MAX_PATH+1]; |
| 10518 | |
| 10519 | char szDrive[_MAX_PATH+1]; |
| 10520 | char szDir[_MAX_PATH+1]; |
| 10521 | char szFile[_MAX_PATH+1]; |
| 10522 | char szExt[_MAX_PATH+1]; |
| 10523 | bool bDiffVol; |
| 10524 | |
| 10525 | // Get local version of our source/dest with full path names, strip trailing \s |
| 10526 | Util_GetFullPathName(szInputSource, szSource); |
| 10527 | Util_GetFullPathName(szInputDest, szDest); |
| 10528 | |
| 10529 | // Check if the files are on different volumes (affects how we do a Move operation) |
| 10530 | bDiffVol = Util_IsDifferentVolumes(szSource, szDest); |
| 10531 | |
| 10532 | // If the source or dest is a directory then add *.* to the end |
| 10533 | if (Util_IsDir(szSource)) |
| 10534 | strcat(szSource, "\\*.*"); |
| 10535 | if (Util_IsDir(szDest)) |
| 10536 | strcat(szDest, "\\*.*"); |
| 10537 | |
| 10538 | |
| 10539 | // Split source into file and extension (we need this info in the loop below to recontstruct the path) |
| 10540 | _splitpath( szSource, szDrive, szDir, szFile, szExt ); |
| 10541 | |
| 10542 | // Note we now rely on the SOURCE being the contents of szDrive, szDir, szFile, etc. |
| 10543 | |
| 10544 | // Does the source file exist? |
| 10545 | hSearch = FindFirstFile(szSource, &findData); |
| 10546 | bLoop = true; |
| 10547 | |
| 10548 | // AutoHotkey: |
| 10549 | int failure_count = 0; |
| 10550 | LONG_OPERATION_INIT |
| 10551 | |
| 10552 | while (hSearch != INVALID_HANDLE_VALUE && bLoop == true) |
| 10553 | { |
| 10554 | LONG_OPERATION_UPDATE // AutoHotkey |
| 10555 | bFound = true; // Found at least one match |
| 10556 | |
| 10557 | // Make sure the returned handle is a file and not a directory before we |
| 10558 | // try and do copy type things on it! |
| 10559 | if ( (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) |
| 10560 | { |
| 10561 | // Expand the destination based on this found file |
| 10562 | Util_ExpandFilenameWildcard(findData.cFileName, szDest, szExpandedDest); |
| 10563 |
nothing calls this directly
no outgoing calls
no test coverage detected