| 618 | } |
| 619 | |
| 620 | bool FileSystemManager::copyFileByName(QString oldPath, QString destDir, QString newFileName, bool confirm, bool silent, bool allowUndo) |
| 621 | { |
| 622 | SHFILEOPSTRUCT fileOperation = { 0 }; |
| 623 | QString fromPath(oldPath), toPath(destDir); |
| 624 | toPath = native(destDir / newFileName); |
| 625 | |
| 626 | TCHAR oldp[MAX_PATH] = {0}; |
| 627 | TCHAR newp[MAX_PATH] = {0}; |
| 628 | lstrcpy(oldp, (LPCTSTR) fromPath.utf16()); |
| 629 | lstrcpy(newp, (LPCTSTR) toPath.utf16()); |
| 630 | |
| 631 | fileOperation.hwnd = winOS->GetWindowsHandle(); |
| 632 | fileOperation.wFunc = FO_COPY; |
| 633 | fileOperation.pFrom = (LPCTSTR) oldp; |
| 634 | fileOperation.pTo = (LPCTSTR) newp; |
| 635 | fileOperation.fFlags = FOF_RENAMEONCOLLISION | (allowUndo ? FOF_ALLOWUNDO : NULL) | (confirm ? NULL : FOF_NOCONFIRMATION) | (silent ? FOF_SILENT : NULL); |
| 636 | |
| 637 | // do the windows file operations for copy |
| 638 | return (SHFileOperation(&fileOperation) == 0) && !fileOperation.fAnyOperationsAborted; |
| 639 | } |
| 640 | |
| 641 | bool FileSystemManager::createFile(QString filePath) |
| 642 | { |