[+] bool IIOHandle::InitFromHandleCopy(const IIOHandle *pHandle)

This commit is contained in:
Reece Wilson 2024-03-15 13:17:21 +00:00
parent 25b1a9cad6
commit 1263434bb7
3 changed files with 21 additions and 3 deletions

View File

@ -95,7 +95,9 @@ namespace Aurora::IO
}
};
virtual bool InitFromHandle(AuSPtr<IIOHandle> pHandle) = 0;
virtual bool InitFromHandle(const AuSPtr<IIOHandle> &pHandle) = 0;
virtual bool InitFromHandleCopy(const IIOHandle *pHandle) = 0;
virtual bool InitFromPath(HandleCreate create) = 0;

View File

@ -52,7 +52,7 @@ namespace Aurora::IO
}
}
bool AFileHandle::InitFromHandle(AuSPtr<IIOHandle> pHandle)
bool AFileHandle::InitFromHandle(const AuSPtr<IIOHandle> &pHandle)
{
auto pSrc = AuStaticCast<AFileHandle>(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;

View File

@ -20,7 +20,7 @@ namespace Aurora::IO
~AFileHandle();
bool InitFromHandle(AuSPtr<IIOHandle> pHandle) override;
bool InitFromHandle(const AuSPtr<IIOHandle> &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;