AuroraRuntime/Source/IO/FS/FSMemoryMappedFile.hpp
Jamie Reece Wilson 66f3250983 [*] Improved IMemoryMappedFile API
[+] AuIO::Adapters::NewAsyncTransactionFromStreamSeekingPair
2024-03-09 00:20:26 +00:00

69 lines
2.9 KiB
C++

/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: FSMemoryMappedFile.hpp
Date: 2024-03-05
Author: Reece
***/
#pragma once
namespace Aurora::IO::FS
{
struct MemoryMappedFile : IMemoryMappedFile, IAsyncFileStream
{
virtual IIOHandle * ToHandle() override;
virtual IAsyncFileStream * ToAsyncFile() override;
virtual AuUInt GetBaseAddress() override;
virtual AuUInt GetEndAddress() override;
virtual AuUInt GetLength() override;
virtual AuSPtr<IStreamReader> NewStreamReader() override;
virtual AuSPtr<IStreamWriter> NewStreamWriter() override;
void InitTransactions();
virtual AuSPtr<IAsyncTransaction> NewAsyncReadTransaction() override;
virtual AuSPtr<IAsyncTransaction> NewAsyncWriteTransaction() override;
virtual AuSPtr<IAsyncTransaction> NewAsyncAnyTransaction() override;
virtual ISeekingReader * ToStreamSeekingReader() override;
virtual ISeekingWriter * ToStreamSeekingWriter() override;
AuMemoryViewRead ToReadView();
AuMemoryViewWrite ToWriteView();
AuMemoryViewRead ToReadViewAlt();
AuMemoryViewWrite ToWriteViewAlt();
virtual void Flush(AuUInt uOffset,
AuUInt uLength) override;
virtual void Prefetch(AuUInt uOffset,
AuUInt uLength) override;
AuSPtr<IAsyncTransaction> NewTransaction() override;
bool BlockingTruncate(AuUInt64 length) override;
bool BlockingRead(AuUInt64 offset, const Memory::MemoryViewStreamWrite &parameters) override;
bool BlockingWrite(AuUInt64 offset, const Memory::MemoryViewStreamRead &parameters) override;
bool Init(EFileOpenMode eMode,
AuUInt64 uFileMapOffset,
AuUInt64 uFileMapLength,
AuInt64 iAdjustStreamOffset,
EFileAdvisoryLockLevel eLockLevel);
AuIOHandle handle;
AuSPtr<AuIO::IIOHandle> pHandleShared;
AuSPtr<AuProcess::IProcessSectionMapView> pView;
AuUInt64 uFileMapLength;
EFileOpenMode eMode;
AuUInt64 uFileMapOffset;
AuInt64 iAdjustStreamOffset;
AuOptional<IO::Buffered::ViewSeekableWriter> optSeekableWriter;
AuOptional<IO::Buffered::ViewSeekableReader> optSeekableReader;
AuInitOnce initOnce;
AuSPtr<IO::Buffered::ViewSeekableReader> pStreamReader;
AuSPtr<IO::Buffered::ViewSeekableWriter> pStreamWriter;
};
}