[*] Cont work on AuIOHandle cleanup

This commit is contained in:
Reece Wilson 2024-03-16 09:51:41 +00:00
parent 1263434bb7
commit 81d7c7027c
8 changed files with 31 additions and 29 deletions

View File

@ -31,29 +31,31 @@ namespace Aurora::IO
this->SharingStop();
}
if (this->uOSWriteHandle.has_value() && this->uOSReadHandle.has_value() &&
this->uOSReadHandle.value() == this->uOSWriteHandle.value())
if (this->uOSWriteHandle.HasValue() && this->uOSReadHandle.HasValue() &&
this->uOSReadHandle.Value() == this->uOSWriteHandle.Value())
{
this->CloseHandle(this->uOSReadHandle.value());
this->CloseHandle(this->uOSReadHandle.Value());
AuResetMember(this->uOSReadHandle);
AuResetMember(this->uOSWriteHandle);
}
if (this->uOSReadHandle)
{
this->CloseHandle(this->uOSReadHandle.value());
this->CloseHandle(this->uOSReadHandle.Value());
AuResetMember(this->uOSReadHandle);
}
if (this->uOSWriteHandle)
{
this->CloseHandle(this->uOSWriteHandle.value());
this->CloseHandle(this->uOSWriteHandle.Value());
AuResetMember(this->uOSWriteHandle);
}
}
bool AFileHandle::InitFromHandle(const AuSPtr<IIOHandle> &pHandle)
{
SysCheckArgNotNull(pHandle, false);
auto pSrc = AuStaticCast<AFileHandle>(pHandle);
auto pDest = this;
@ -115,7 +117,7 @@ namespace Aurora::IO
if (optOSReadHandle)
{
if (auto uOSReadHandle2 = this->DupHandle(optOSReadHandle.value(), false))
if (auto uOSReadHandle2 = this->DupHandle(optOSReadHandle.Value(), false))
{
this->uOSReadHandle = uOSReadHandle2;
}
@ -127,13 +129,13 @@ namespace Aurora::IO
if (optOSWriteHandle)
{
if (auto uOSWriteHandle2 = this->DupHandle(optOSWriteHandle.value(), true))
if (auto uOSWriteHandle2 = this->DupHandle(optOSWriteHandle.Value(), true))
{
this->uOSWriteHandle = uOSWriteHandle2;
}
else
{
this->CloseHandle(this->uOSReadHandle.value());
this->CloseHandle(this->uOSReadHandle.Value());
AuResetMember(this->uOSReadHandle);
return {};
}
@ -180,12 +182,12 @@ namespace Aurora::IO
if (auto optFile = this->optIsFile)
{
return optFile.value();
return optFile.Value();
}
if (auto optHandle = this->GetOSHandleSafe())
{
bIsFile = IsHandleFile(optHandle.value());
bIsFile = IsHandleFile(optHandle.Value());
}
else
{
@ -203,12 +205,12 @@ namespace Aurora::IO
if (auto optTTY = this->optIsTTY)
{
return optTTY.value();
return optTTY.Value();
}
if (auto optHandle = this->GetOSHandleSafe())
{
bIsTTY = IsHandleTTY(optHandle.value());
bIsTTY = IsHandleTTY(optHandle.Value());
}
else
{
@ -236,12 +238,12 @@ namespace Aurora::IO
if (auto optPipe = this->optIsPipe)
{
return optPipe.value();
return optPipe.Value();
}
if (auto optHandle = this->GetOSHandleSafe())
{
bIsPipe = IsHandlePipe(optHandle.value());
bIsPipe = IsHandlePipe(optHandle.Value());
}
else
{
@ -278,7 +280,7 @@ namespace Aurora::IO
AuUInt64 AFileHandle::GetOSReadHandle() const
{
return this->uOSReadHandle.value();
return this->uOSReadHandle.Value();
}
AuOptionalEx<AuUInt64> AFileHandle::GetOSReadHandleSafe() const
@ -288,7 +290,7 @@ namespace Aurora::IO
AuUInt64 AFileHandle::GetOSWriteHandle() const
{
return this->uOSWriteHandle.value();
return this->uOSWriteHandle.Value();
}
AuOptionalEx<AuUInt64> AFileHandle::GetOSWriteHandleSafe() const

View File

@ -147,7 +147,7 @@ namespace Aurora::IO::FS
if (!pFSReader)
{
pFSReader = AuFS::OpenBlockingFileStreamFromHandle(this->pHandle_);
pFSReader = OpenBlockingFileStreamFromHandleShared(this->pHandle_);
}
if (!pFSReader)

View File

@ -84,7 +84,7 @@ namespace Aurora::IO::FS
if (!pFSReader)
{
pFSReader = AuFS::OpenBlockingFileStreamFromHandle(this->pHandle_);
pFSReader = OpenBlockingFileStreamFromHandleShared(this->pHandle_);
}
if (!pFSReader)

View File

@ -388,7 +388,7 @@ namespace Aurora::IO::FS
return false;
}
auto pStream = FS::OpenBlockingFileStreamFromHandle(AuUnsafeRaiiToShared(handle.AsPointer()));
auto pStream = OpenBlockingFileStreamFromHandleShared(AuUnsafeRaiiToShared(handle.AsPointer()));
if (!pStream)
{
return false;
@ -430,7 +430,7 @@ namespace Aurora::IO::FS
return false;
}
auto pStream = FS::OpenBlockingFileStreamFromHandle(AuUnsafeRaiiToShared(handle.AsPointer()));
auto pStream = OpenBlockingFileStreamFromHandleShared(AuUnsafeRaiiToShared(handle.AsPointer()));
if (!pStream)
{
return false;
@ -468,7 +468,7 @@ namespace Aurora::IO::FS
return false;
}
auto pStream = FS::OpenBlockingFileStreamFromHandle(AuUnsafeRaiiToShared(handle.AsPointer()));
auto pStream = FS::OpenBlockingFileStreamFromHandleShared(AuUnsafeRaiiToShared(handle.AsPointer()));
if (!pStream)
{
return false;

View File

@ -118,7 +118,7 @@ namespace Aurora::IO::IPC
AuStaticCast<AFileHandle>(this->fsHandle_)->bIsAsync = true;
AuStaticCast<AFileHandle>(this->fsHandle_)->pIPCPipe = this;
this->fsBlockingStream_ = AuFS::OpenBlockingFileStreamFromHandle(this->fsHandle_);
this->fsBlockingStream_ = AuFS::OpenBlockingFileStreamFromHandleShared(this->fsHandle_);
if (!this->fsBlockingStream_)
{
this->bDead = true;

View File

@ -188,7 +188,7 @@ namespace Aurora::IO::IPC
(void)this->fsHandle_->InitFromPairMove(fds2[0], fds2[1]);
this->fsStream_->Init(this->fsHandle_);
this->fsBlockingStream_ = AuFS::OpenBlockingFileStreamFromHandle(this->fsHandle_);
this->fsBlockingStream_ = AuFS::OpenBlockingFileStreamFromHandleShared(this->fsHandle_);
if (!this->fsBlockingStream_)
{
this->bDead = true;

View File

@ -542,7 +542,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetErrorStreamHandle())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamReader() };
}
@ -552,7 +552,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetOutputAndInputHandles())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamReader() };
}
@ -566,7 +566,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetErrorStreamHandle())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamWriter() };
}

View File

@ -524,7 +524,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetErrorStreamHandle())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamReader() };
}
@ -534,7 +534,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetOutputAndInputHandles())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamReader() };
}
@ -548,7 +548,7 @@ namespace Aurora::Processes
{
if (auto pThat = this->GetErrorStreamHandle())
{
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandle(pThat))
if (auto pThat2 = AuFS::OpenBlockingFileStreamFromHandleShared(pThat))
{
return { pThat2, pThat2->ToStreamWriter() };
}