| 850 | SC_TRY( |
| 851 | FileSystem::Operations::copyFile(copyFileData.path, copyFileData.destinationPath, copyFileData.copyFlags)); |
| 852 | return SC::Result(true); |
| 853 | }; |
| 854 | loopWork.callback.bind<AsyncFileSystemOperation, &AsyncFileSystemOperation::onOperationCompleted>(*this); |
| 855 | return eventLoop.start(loopWork); |
| 856 | } |
| 857 | |
| 858 | SC::Result SC::AsyncFileSystemOperation::rename(AsyncEventLoop& eventLoop, StringSpan path, StringSpan newPath) |
| 859 | { |
| 860 | SC_TRY(checkState()); |
| 861 | operation = Operation::Rename; |
| 862 | new (&renameData, PlacementNew()) RenameData({path, newPath}); |
| 863 | if (not eventLoop.needsThreadPoolForFileOperations() and threadPoolMode != AsyncThreadPoolMode::ForceThreadPool) |
| 864 | { |
| 865 | return eventLoop.start(*this); |
| 866 | } |
| 867 | |
| 868 | loopWork.work = [&]() |
| 869 | { |
| 870 | SC_TRY(FileSystem::Operations::rename(renameData.path, renameData.newPath)); |
| 871 | return SC::Result(true); |
| 872 | }; |