diff --git a/Source/IO/FS/Async.Linux.cpp b/Source/IO/FS/Async.Linux.cpp index dd01b784..b5cedf9f 100644 --- a/Source/IO/FS/Async.Linux.cpp +++ b/Source/IO/FS/Async.Linux.cpp @@ -139,7 +139,9 @@ namespace Aurora::IO::FS AuSPtr LinuxAsyncFileStream::NewTransaction() { - if (!AuStaticCast(this->pHandle_)->bDirectIO) + if (!this->pProcessBlock_ && + !AuStaticCast(this->pHandle_)->bDirectIO && + !AuStaticCast(this->pHandle_)->pIPCPipe) { auto &pFSReader = this->pCache_; diff --git a/Source/IO/FS/Async.NT.cpp b/Source/IO/FS/Async.NT.cpp index 4c12c909..6164d9ef 100644 --- a/Source/IO/FS/Async.NT.cpp +++ b/Source/IO/FS/Async.NT.cpp @@ -78,10 +78,31 @@ namespace Aurora::IO::FS AuSPtr 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(); SysCheckNotNullMemory(shared, {}); - if (!shared->InitWeak(this->pHandle_)) + //if (!shared->InitWeak(this->pHandle_)) + if (!shared->Init(this->pHandle_)) { return {}; } diff --git a/Source/IO/FS/Async.NT.hpp b/Source/IO/FS/Async.NT.hpp index 4e3e8358..7f778c0f 100644 --- a/Source/IO/FS/Async.NT.hpp +++ b/Source/IO/FS/Async.NT.hpp @@ -28,6 +28,7 @@ namespace Aurora::IO::FS private: AuSPtr pHandle_; + AuSPtr pCache_; }; struct NtAsyncFileTransaction :