AuroraRuntime/Source/IO/AuIOHandle.hpp
Jamie Reece Wilson 232a136bfe [+] IOHandle::IsWriteEoSOnClose
[+] IOHandle::SetWriteEoSOnClose
[+] IOHandle::HandleCreate::bFlushOnClose
[+] IOHandle::HandleCreate::bWriteEoSOnClose
[*] Unified grug based auto-truncating. Previously we were truncating on the final derefing thread; now, we truncate on the grug thread.
[*] Refactor/Cleanup IOHandle
2024-03-27 03:15:01 +00:00

117 lines
3.4 KiB
C++

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuIOHandle.hpp
Date: 2023-7-28
Author: Reece
***/
#pragma once
namespace Aurora::IO::IPC
{
struct IPCPipeImpl;
}
namespace Aurora::IO
{
struct AFileHandle : IIOHandle
{
AFileHandle();
~AFileHandle();
bool InitFromHandle(const AuSPtr<IIOHandle> &pHandle) override;
bool InitFromCopy(AuUInt64 uOSHandle) override;
bool InitFromMove(AuUInt64 uOSHandle) override;
bool InitFromPair(AuOptional<AuUInt64> uOSReadHandle,
AuOptional<AuUInt64> uOSWriteHandle) override;
bool InitFromPairMove(AuOptional<AuUInt64> uOSReadHandle,
AuOptional<AuUInt64> uOSWriteHandle) override;
bool InitFromStreamEnum(EStandardStream eStream) override;
bool InitFromHandleCopy(const IIOHandle *pHandle) override;
bool InitFromSharing(const AuString &handle) override;
bool InitFromPath(HandleCreate create) override;
AuUInt64 GetOSHandle() const override;
AuOptional<AuUInt64> GetOSHandleSafe() const override;
AuUInt64 GetOSReadHandle() const override;
AuOptional<AuUInt64> GetOSReadHandleSafe() const override;
AuUInt64 GetOSWriteHandle() const override;
AuOptional<AuUInt64> GetOSWriteHandleSafe() const override;
bool IsValid() const override;
bool HasUniqueWriteHandle()const override;
bool IsAsync() const override;
const AuString &GetPath() const override;
bool IsFile() const override;
bool IsTTY() const override;
bool IsPipe() const override;
bool IsFlushOnClose() const override;
void SetFlushOnClose(bool bFlushOnClose) override;
bool IsWriteEoSOnClose() const override;
void SetWriteEoSOnClose(bool bShouldWriteEoS) override;
void InitStdIn(bool bSharing = false);
void InitStdOut(bool bError = false, bool bSharing = false);
bool SectionLock(AuUInt64 uOffset,
AuUInt64 uLength,
FS::EFileAdvisoryLockLevel level) override;
bool SectionUnlock(AuUInt64 uOffset,
AuUInt64 uLength) override;
AuString SharingGetString() override;
bool SharingIsShared() override;
void SharingStop() override;
AuUInt64 GetFileLength() override;
bool ShouldClone();
AuOptional<AuUInt64> uOSWriteHandle;
AuOptional<AuUInt64> uOSReadHandle;
AuSPtr<IIOHandle> pThat;
AuString path;
IPC::IPCPipeImpl *pIPCPipe {};
mutable AuOptional<bool> optIsFile;
mutable AuOptional<bool> optIsPipe;
mutable AuOptional<bool> optIsTTY;
mutable AuSPtr<AuString> pIPCString;
AuUInt uThreadId {};
bool bIsAsync {}, bFlushOnClose {}, bShouldWriteEoS {}, bDirectIO {};
protected:
// Implement me:
// bool InitFromPath(HandleCreate create) override;
static AuUInt64 DupHandle(AuUInt64 uOSHandle, bool bWriteAccess);
static AuUInt64 DupHandle(AuUInt64 uOSHandle, bool bWriteAccess, bool bShareAccess);
static void CloseHandle(AuUInt64 uOSHandle, bool bFlushOnClose, bool bWriteEoS);
inline void CloseHandle(AuUInt64 uOSHandle)
{
CloseHandle(uOSHandle, this->bFlushOnClose, false);
}
};
}