2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-04-04 07:53:34 +00:00
|
|
|
File: FileStream.Unix.hpp
|
2021-06-27 21:25:29 +00:00
|
|
|
Date: 2021-6-12
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if !defined(_AURUNTIME_GENERICFILESTREAM)
|
|
|
|
|
|
|
|
namespace Aurora::IO::FS
|
|
|
|
{
|
2022-04-17 14:51:37 +00:00
|
|
|
// Code-sharing for async API fallbacks...
|
|
|
|
bool PosixSetOffset(int fd, AuUInt64 offset);
|
2023-08-11 15:51:42 +00:00
|
|
|
AuUInt64 PosixGetLength(int fd);
|
2022-04-17 14:51:37 +00:00
|
|
|
bool PosixRead(int fd, void *buf, AuUInt32 count, AuUInt32 *pRead);
|
|
|
|
bool PosixWrite(int fd, const void *buf, AuUInt32 count, AuUInt32 *pWritten);
|
|
|
|
|
2022-08-10 09:50:49 +00:00
|
|
|
struct PosixFileStream : IFileStream
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2021-10-02 16:07:33 +00:00
|
|
|
~PosixFileStream();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2023-08-11 15:51:42 +00:00
|
|
|
bool Init(AuSPtr<IIOHandle> pHandle);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
AuUInt64 GetOffset() override;
|
|
|
|
bool SetOffset(AuUInt64 offset) override;
|
|
|
|
AuUInt64 GetLength() override;
|
2021-10-02 16:07:33 +00:00
|
|
|
bool Read(const Memory::MemoryViewStreamWrite ¶meters) override;
|
|
|
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override;
|
2021-06-27 21:25:29 +00:00
|
|
|
void Close() override;
|
|
|
|
void Flush() override;
|
2022-03-22 03:53:08 +00:00
|
|
|
void WriteEoS() override;
|
2022-04-04 07:53:34 +00:00
|
|
|
void MakeTemporary() override;
|
2023-08-11 15:51:42 +00:00
|
|
|
AuSPtr<IIOHandle> GetHandle() override;
|
|
|
|
int GetUnixHandle();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
private:
|
2023-08-11 15:51:42 +00:00
|
|
|
AuSPtr<IIOHandle> pHandle_;
|
2021-09-06 10:58:08 +00:00
|
|
|
AuString path_;
|
2022-04-04 07:53:34 +00:00
|
|
|
AuThreadPrimitives::SpinLock spinlock_;
|
|
|
|
bool bMadeTemporary {};
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
|
|
|
}
|
2022-03-22 03:53:08 +00:00
|
|
|
#endif
|