91 lines
2.5 KiB
C++
91 lines
2.5 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
|
|
{
|
|
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;
|
|
|
|
bool InitFromPath(HandleCreate create) override;
|
|
|
|
AuUInt64 GetOSHandle() override;
|
|
|
|
AuOptionalEx<AuUInt64> GetOSHandleSafe() override;
|
|
|
|
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);
|
|
|
|
bool SectionLock(AuUInt64 uOffset,
|
|
AuUInt64 uLength,
|
|
FS::EFileAdvisoryLockLevel level) override;
|
|
|
|
bool SectionUnlock(AuUInt64 uOffset,
|
|
AuUInt64 uLength) override;
|
|
|
|
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;
|
|
|
|
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);
|
|
};
|
|
} |