blob: 0c8ef340a79bb1520d8d0529dd0027cb2243d874 (
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
  | 
#pragma once
#include "../../PreConfig.h"
#ifdef CRU_PLATFORM_UNIX
#include "../../String.h"
#include "../../io/OpenFileFlag.h"
#include "../../io/Stream.h"
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 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
 
  |