| 68 | } |
| 69 | |
| 70 | static AwaitTask copyThenSend(AwaitEventLoop& await, ThreadPool& threadPool, StringSpan sourcePath, StringSpan copyPath, |
| 71 | SocketDescriptor& sender, SocketDescriptor& receiver, Span<char> receiveBuffer, |
| 72 | AwaitSocketReceiveResult& received) |
| 73 | { |
| 74 | SC_CO_TRY(co_await await.fsCopyFile(threadPool, sourcePath, copyPath)); |
| 75 | |
| 76 | FileDescriptor copiedFile; |
| 77 | SC_CO_TRY(co_await await.fsOpen(threadPool, copyPath, FileOpen::Read, copiedFile)); |
| 78 | |
| 79 | AwaitFileSendOptions sendOptions; |
| 80 | sendOptions.threadPool = &threadPool; |
| 81 | sendOptions.length = receiveBuffer.sizeInBytes(); |
| 82 | |
| 83 | AwaitFileSendResult sendResult; |
| 84 | SC_CO_TRY(co_await await.fileSend(copiedFile, sender, sendResult, sendOptions)); |
| 85 | SC_CO_TRY(co_await await.fsClose(threadPool, copiedFile)); |
| 86 | |
| 87 | if (not sendResult.complete or sendResult.bytesTransferred != receiveBuffer.sizeInBytes()) |
| 88 | { |
| 89 | co_return Result::Error("AwaitFileCourier incomplete fileSend"); |
| 90 | } |
| 91 | |
| 92 | SC_CO_TRY(co_await await.receiveExact(receiver, receiveBuffer, &received)); |
| 93 | co_return Result(true); |
| 94 | } |
| 95 | |
| 96 | static Result runAwaitFileCourier() |
| 97 | { |
no test coverage detected