From 1263434bb77b9dde60d3417f2d307420357790c6 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Fri, 15 Mar 2024 13:17:21 +0000 Subject: [PATCH] [+] bool IIOHandle::InitFromHandleCopy(const IIOHandle *pHandle) --- Include/Aurora/IO/IOHandle.hpp | 4 +++- Source/IO/AuIOHandle.cpp | 16 +++++++++++++++- Source/IO/AuIOHandle.hpp | 4 +++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Include/Aurora/IO/IOHandle.hpp b/Include/Aurora/IO/IOHandle.hpp index 9655ef4e..911cff3c 100644 --- a/Include/Aurora/IO/IOHandle.hpp +++ b/Include/Aurora/IO/IOHandle.hpp @@ -95,7 +95,9 @@ namespace Aurora::IO } }; - virtual bool InitFromHandle(AuSPtr pHandle) = 0; + virtual bool InitFromHandle(const AuSPtr &pHandle) = 0; + + virtual bool InitFromHandleCopy(const IIOHandle *pHandle) = 0; virtual bool InitFromPath(HandleCreate create) = 0; diff --git a/Source/IO/AuIOHandle.cpp b/Source/IO/AuIOHandle.cpp index 5a427860..5561e0aa 100644 --- a/Source/IO/AuIOHandle.cpp +++ b/Source/IO/AuIOHandle.cpp @@ -52,7 +52,7 @@ namespace Aurora::IO } } - bool AFileHandle::InitFromHandle(AuSPtr pHandle) + bool AFileHandle::InitFromHandle(const AuSPtr &pHandle) { auto pSrc = AuStaticCast(pHandle); auto pDest = this; @@ -66,6 +66,7 @@ namespace Aurora::IO pDest->uOSReadHandle = pSrc->uOSReadHandle; pDest->uOSWriteHandle = pSrc->uOSWriteHandle; pDest->bIsAsync = pSrc->bIsAsync; + pDest->uThreadId = pSrc->uThreadId; return true; } @@ -80,6 +81,7 @@ namespace Aurora::IO { this->uOSReadHandle = uOSWriteHandle; this->uOSWriteHandle = uOSWriteHandle; + this->uThreadId = AuUInt(AuThreads::GetThreadId()); return true; } else @@ -97,6 +99,7 @@ namespace Aurora::IO this->uOSReadHandle = uOSHandle; this->uOSWriteHandle = uOSHandle; + this->uThreadId = AuUInt(AuThreads::GetThreadId()); return true; } @@ -108,6 +111,8 @@ namespace Aurora::IO return false; } + this->uThreadId = AuUInt(AuThreads::GetThreadId()); + if (optOSReadHandle) { if (auto uOSReadHandle2 = this->DupHandle(optOSReadHandle.value(), false)) @@ -147,6 +152,7 @@ namespace Aurora::IO this->uOSReadHandle = uOSReadHandle; this->uOSWriteHandle = uOSWriteHandle; + this->uThreadId = AuUInt(AuThreads::GetThreadId()); return true; } @@ -357,9 +363,17 @@ namespace Aurora::IO this->uOSWriteHandle = uOSWriteHandle; #endif + this->uThreadId = AuUInt(AuThreads::GetThreadId()); return true; } + bool AFileHandle::InitFromHandleCopy(const IIOHandle *pHandle) + { + SysCheckArgNotNull(pHandle, false); + + return this->InitFromPair(pHandle->GetOSReadHandleSafe(), pHandle->GetOSWriteHandleSafe()); + } + AuString AFileHandle::SharingGetString() { AuString handle; diff --git a/Source/IO/AuIOHandle.hpp b/Source/IO/AuIOHandle.hpp index 3b2f8bc0..665f5398 100644 --- a/Source/IO/AuIOHandle.hpp +++ b/Source/IO/AuIOHandle.hpp @@ -20,7 +20,7 @@ namespace Aurora::IO ~AFileHandle(); - bool InitFromHandle(AuSPtr pHandle) override; + bool InitFromHandle(const AuSPtr &pHandle) override; bool InitFromCopy(AuUInt64 uOSHandle) override; @@ -34,6 +34,8 @@ namespace Aurora::IO bool InitFromStreamEnum(EStandardStream eStream) override; + bool InitFromHandleCopy(const IIOHandle *pHandle) override; + bool InitFromSharing(const AuString &handle) override; bool InitFromPath(HandleCreate create) override;