44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: FileStream.Unix.hpp
|
|
Date: 2021-6-12
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#if !defined(_AURUNTIME_GENERICFILESTREAM)
|
|
|
|
namespace Aurora::IO::FS
|
|
{
|
|
// Code-sharing for async API fallbacks...
|
|
bool PosixSetOffset(int fd, AuUInt64 offset);
|
|
bool PosixRead(int fd, void *buf, AuUInt32 count, AuUInt32 *pRead);
|
|
bool PosixWrite(int fd, const void *buf, AuUInt32 count, AuUInt32 *pWritten);
|
|
|
|
struct PosixFileStream : IFileStream
|
|
{
|
|
~PosixFileStream();
|
|
|
|
bool Init(int handle, const AuString &path);
|
|
|
|
AuUInt64 GetOffset() override;
|
|
bool SetOffset(AuUInt64 offset) override;
|
|
AuUInt64 GetLength() override;
|
|
bool Read(const Memory::MemoryViewStreamWrite ¶meters) override;
|
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override;
|
|
void Close() override;
|
|
void Flush() override;
|
|
void WriteEoS() override;
|
|
void MakeTemporary() override;
|
|
|
|
int GetHandle();
|
|
private:
|
|
|
|
int handle_ = -1;
|
|
AuString path_;
|
|
AuThreadPrimitives::SpinLock spinlock_;
|
|
bool bMadeTemporary {};
|
|
};
|
|
}
|
|
#endif |