MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / write

Method write

Libraries/Async/Async.cpp:773–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

771}
772
773SC::Result SC::AsyncFileSystemOperation::write(AsyncEventLoop& eventLoop, FileDescriptor::Handle handle,
774 Span<const char> buffer, uint64_t offset)
775{
776 SC_TRY(checkState());
777 operation = Operation::Write;
778 new (&writeData, PlacementNew()) WriteData({handle, buffer, offset});
779 if (not eventLoop.needsThreadPoolForFileOperations() and threadPoolMode != AsyncThreadPoolMode::ForceThreadPool)
780 {
781 return eventLoop.start(*this);
782 }
783
784 loopWork.work = [&]()
785 {
786 FileDescriptor fd(writeData.handle);
787 SC::Result writeResult = fd.write(writeData.buffer, writeData.offset);
788 fd.detach();
789 SC_TRY(writeResult);
790 completionData.numBytes = writeData.buffer.sizeInBytes();
791 return SC::Result(true);
792 };
793 loopWork.callback.bind<AsyncFileSystemOperation, &AsyncFileSystemOperation::onOperationCompleted>(*this);
794 return eventLoop.start(loopWork);
795}
796
797SC::Result SC::AsyncFileSystemOperation::copyFile(AsyncEventLoop& eventLoop, StringSpan path,
798 StringSpan destinationPath, FileSystemCopyFlags copyFlags)

Callers 1

await_suspendMethod · 0.45

Calls 6

PlacementNewClass · 0.85
ResultClass · 0.70
startMethod · 0.45
detachMethod · 0.45
sizeInBytesMethod · 0.45

Tested by

no test coverage detected