Jamie Reece Wilson
ce1ae24506
[+] IIOHandle::SharingGetString [+] IIOHandle::SharingIsShared [+] IIOHandle::SharingStop [+] HANDLEPipeServer.[h/c]pp
106 lines
3.1 KiB
C++
106 lines
3.1 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();
|
|
|
|
bool InitFromHandle(AuSPtr<IIOHandle> pHandle) override;
|
|
|
|
bool InitFromCopy(AuUInt64 uOSHandle) override;
|
|
|
|
bool InitFromMove(AuUInt64 uOSHandle) override;
|
|
|
|
bool InitFromPair(AuOptionalEx<AuUInt64> uOSReadHandle,
|
|
AuOptionalEx<AuUInt64> uOSWriteHandle) override;
|
|
|
|
bool InitFromPairMove(AuOptionalEx<AuUInt64> uOSReadHandle,
|
|
AuOptionalEx<AuUInt64> uOSWriteHandle) override;
|
|
|
|
bool InitFromStreamEnum(EStandardStream eStream) override;
|
|
|
|
bool InitFromSharing(const AuString &handle) override;
|
|
|
|
bool InitFromPath(HandleCreate create) override;
|
|
|
|
AuUInt64 GetOSHandle() const override;
|
|
|
|
AuOptionalEx<AuUInt64> GetOSHandleSafe() const override;
|
|
|
|
AuUInt64 GetOSReadHandle() const override;
|
|
|
|
AuOptionalEx<AuUInt64> GetOSReadHandleSafe() const override;
|
|
|
|
AuUInt64 GetOSWriteHandle() const override;
|
|
|
|
AuOptionalEx<AuUInt64> GetOSWriteHandleSafe() const override;
|
|
|
|
bool IsValid() const override;
|
|
|
|
bool HasUniqueWriteHandle()const override;
|
|
|
|
bool IsAsync() const override;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
AuOptionalEx<AuUInt64> uOSWriteHandle;
|
|
AuOptionalEx<AuUInt64> uOSReadHandle;
|
|
AuSPtr<IIOHandle> pThat;
|
|
bool bIsAsync {}, bFlushOnClose {};
|
|
AuString path;
|
|
IPC::IPCPipeImpl *pIPCPipe {};
|
|
bool bDirectIO {};
|
|
mutable AuOptional<bool> optIsFile;
|
|
mutable AuOptional<bool> optIsPipe;
|
|
mutable AuOptional<bool> optIsTTY;
|
|
mutable AuSPtr<AuString> pIPCString;
|
|
|
|
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);
|
|
|
|
inline void CloseHandle(AuUInt64 uOSHandle)
|
|
{
|
|
CloseHandle(uOSHandle, this->bFlushOnClose);
|
|
}
|
|
};
|
|
} |