AuroraRuntime/Source/IO/AuIOHandle.hpp

82 lines
2.1 KiB
C++
Raw Normal View History

2023-07-29 07:02:47 +00:00
/***
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;
}
2023-07-29 07:02:47 +00:00
namespace Aurora::IO
{
struct AFileHandle : IIOHandle
{
virtual ~AFileHandle();
bool InitFromHandle(AuSPtr<IIOHandle> pHandle) override;
bool InitFromCopy(AuUInt64 uOSHandle) override;
bool InitFromMove(AuUInt64 uOSHandle) override;
bool InitFromPair(AuUInt64 uOSReadHandle,
AuUInt64 uOSWriteHandle) override;
bool InitFromPairMove(AuOptionalEx<AuUInt64> uOSReadHandle,
AuOptionalEx<AuUInt64> uOSWriteHandle) override;
bool InitFromStreamEnum(EStandardStream eStream) override;
2023-07-29 07:02:47 +00:00
AuUInt64 GetOSHandle() override;
AuOptionalEx<AuUInt64> GetOSHandleSafe() override;
2023-07-29 07:02:47 +00:00
AuUInt64 GetOSReadHandle() override;
AuOptionalEx<AuUInt64> GetOSReadHandleSafe() override;
AuUInt64 GetOSWriteHandle() override;
AuOptionalEx<AuUInt64> GetOSWriteHandleSafe() override;
bool IsValid() override;
bool HasUniqueWriteHandle() override;
bool IsAsync() override;
AuString GetPath() override;
bool IsFile() override;
bool IsTTY() override;
bool IsPipe() override;
void InitStdIn(bool bSharing = false);
void InitStdOut(bool bError = false, bool bSharing = false);
2023-07-29 07:02:47 +00:00
AuOptionalEx<AuUInt64> uOSWriteHandle;
AuOptionalEx<AuUInt64> uOSReadHandle;
AuSPtr<IIOHandle> pThat;
bool bIsAsync {};
AuString path;
IPC::IPCPipeImpl *pIPCPipe {};
bool bDirectIO {};
AuOptionalEx<bool> optIsFile;
AuOptionalEx<bool> optIsPipe;
AuOptionalEx<bool> optIsTTY;
2023-07-29 07:02:47 +00:00
protected:
// Implement me:
// bool InitFromPath(HandleCreate create) override;
static AuUInt64 DupHandle(AuUInt64 uOSHandle, bool bWriteAccess);
static AuUInt64 DupHandle(AuUInt64 uOSHandle, bool bWriteAccess, bool bShareAccess);
2023-07-29 07:02:47 +00:00
static void CloseHandle(AuUInt64 uOSHandle);
};
}