| 8425 | |
| 8426 | #ifndef AUTOHOTKEYSC |
| 8427 | bool Line::FileInstallCopy(LPTSTR aSource, LPTSTR aDest, bool aOverwrite) |
| 8428 | { |
| 8429 | // v1.0.35.11: Must search in A_ScriptDir by default because that's where ahk2exe will search by default. |
| 8430 | // The old behavior was to search in A_WorkingDir, which seems pointless because ahk2exe would never |
| 8431 | // be able to use that value if the script changes it while running. |
| 8432 | TCHAR source_path[T_MAX_PATH], dest_path[T_MAX_PATH]; |
| 8433 | GetFullPathName(aDest, _countof(dest_path), dest_path, NULL); |
| 8434 | // Avoid attempting the copy if both paths are the same (since it would fail with ERROR_SHARING_VIOLATION), |
| 8435 | // but resolve both to full paths in case mFileDir != g_WorkingDir. There is a more thorough way to detect |
| 8436 | // when two *different* paths refer to the same file, but it doesn't work with different network shares, and |
| 8437 | // the additional complexity wouldn't be warranted. Also, the limitations of this method are clearer. |
| 8438 | SetCurrentDirectory(g_script.mFileDir); |
| 8439 | GetFullPathName(aSource, _countof(source_path), source_path, NULL); |
| 8440 | SetCurrentDirectory(g_WorkingDir); // Restore to proper value. |
| 8441 | if (!lstrcmpi(source_path, dest_path) // Full paths are equal. |
| 8442 | && !(GetFileAttributes(source_path) & FILE_ATTRIBUTE_DIRECTORY)) // Source file exists and is not a directory (otherwise, an error should be thrown). |
| 8443 | return true; |
| 8444 | |
| 8445 | return CopyFile(source_path, dest_path, !aOverwrite); |
| 8446 | } |
| 8447 | #endif |
| 8448 | |
| 8449 |
nothing calls this directly
no outgoing calls
no test coverage detected