blob: 633b9bd1350877f4927ba3477623157f4ea5b17e (
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 "OpenFileFlag.hpp"
#include "Stream.hpp"
namespace cru::io {
class UnixFileStream : public Stream {
 public:
  UnixFileStream(String path, 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_;
  OpenFileFlag flags_;
  int file_descriptor_;
  bool closed_ = false;
};
}  // namespace cru::io
#endif
 |