blob: 618f7aa346ec19ec426a7d5241663adbf52467de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma once
#include "../../PreConfig.hpp"
#ifdef CRU_PLATFORM_UNIX
#include "../../String.hpp"
#include "../../io/OpenFileFlag.hpp"
#include "../../io/Stream.hpp"
namespace cru::platform::unix {
class UnixFileStream : public io::Stream {
public:
UnixFileStream(String path, io::OpenFileFlag flags);
CRU_DELETE_COPY(UnixFileStream)
CRU_DELETE_MOVE(UnixFileStream)
~UnixFileStream() override;
public:
bool CanSeek() override;
Index Tell() override;
void Seek(Index offset, SeekOrigin origin = SeekOrigin::Current) override;
bool CanRead() override;
Index Read(std::byte* buffer, Index offset, Index size) override;
using Stream::Read;
bool CanWrite() override;
Index Write(const std::byte* buffer, Index offset, Index size) override;
using Stream::Write;
void Close() override;
private:
void CheckClosed();
private:
String path_;
io::OpenFileFlag flags_;
int file_descriptor_;
bool closed_ = false;
};
} // namespace cru::platform::unix
#endif
|