[*] Update IAsyncFileStream::NewTransaction

This commit is contained in:
Reece Wilson 2024-03-09 01:08:56 +00:00
parent a9fd9221b7
commit 9a846a6d2f
3 changed files with 26 additions and 2 deletions

View File

@ -139,7 +139,9 @@ namespace Aurora::IO::FS
AuSPtr<IAsyncTransaction> LinuxAsyncFileStream::NewTransaction() AuSPtr<IAsyncTransaction> LinuxAsyncFileStream::NewTransaction()
{ {
if (!AuStaticCast<AuIO::AFileHandle>(this->pHandle_)->bDirectIO) if (!this->pProcessBlock_ &&
!AuStaticCast<AuIO::AFileHandle>(this->pHandle_)->bDirectIO &&
!AuStaticCast<AuIO::AFileHandle>(this->pHandle_)->pIPCPipe)
{ {
auto &pFSReader = this->pCache_; auto &pFSReader = this->pCache_;

View File

@ -78,10 +78,31 @@ namespace Aurora::IO::FS
AuSPtr<IAsyncTransaction> NtAsyncFileStream::NewTransaction() AuSPtr<IAsyncTransaction> NtAsyncFileStream::NewTransaction()
{ {
if (!this->pHandle_->IsAsync())
{
auto &pFSReader = this->pCache_;
if (!pFSReader)
{
pFSReader = AuFS::OpenBlockingFileStreamFromHandle(this->pHandle_);
}
if (!pFSReader)
{
SysPushErrorNested();
return {};
}
auto pStreamReader = AuSharedPointerFromShared(pFSReader->ToStreamSeekingReader(), pFSReader);
auto pStreamWriter = AuSharedPointerFromShared(pFSReader->ToStreamSeekingWriter(), pFSReader);
return Adapters::NewAsyncTransactionFromStreamSeekingPair(pStreamReader, pStreamWriter, {});
}
auto shared = AuMakeShared<NtAsyncFileTransaction>(); auto shared = AuMakeShared<NtAsyncFileTransaction>();
SysCheckNotNullMemory(shared, {}); SysCheckNotNullMemory(shared, {});
if (!shared->InitWeak(this->pHandle_)) //if (!shared->InitWeak(this->pHandle_))
if (!shared->Init(this->pHandle_))
{ {
return {}; return {};
} }

View File

@ -28,6 +28,7 @@ namespace Aurora::IO::FS
private: private:
AuSPtr<IIOHandle> pHandle_; AuSPtr<IIOHandle> pHandle_;
AuSPtr<IFileStream> pCache_;
}; };
struct NtAsyncFileTransaction : struct NtAsyncFileTransaction :