Etterna 0.74.4
Loading...
Searching...
No Matches
RageFileDriverDirect.h
1#ifndef RAGE_FILE_DRIVER_DIRECT_H
2#define RAGE_FILE_DRIVER_DIRECT_H
3
4#include "RageFile.h"
5#include "RageFileDriver.h"
6
9{
10 public:
11 explicit RageFileDriverDirect(const std::string& sRoot);
12
13 RageFileBasic* Open(const std::string& sPath,
14 int iMode,
15 int& iError) override;
16 bool Move(const std::string& sOldPath,
17 const std::string& sNewPath) override;
18 bool Remove(const std::string& sPath) override;
19 bool Remount(const std::string& sPath) override;
20
21 private:
22 std::string m_sRoot;
23};
24
26{
27 public:
28 explicit RageFileDriverDirectReadOnly(const std::string& sRoot);
29 RageFileBasic* Open(const std::string& sPath,
30 int iMode,
31 int& iError) override;
32 bool Move(const std::string& sOldPath,
33 const std::string& sNewPath) override;
34 bool Remove(const std::string& sPath) override;
35};
36
40{
41 public:
42 RageFileObjDirect(const std::string& sPath, int iFD, int iMode);
43 ~RageFileObjDirect() override;
44 int ReadInternal(void* pBuffer, size_t iBytes) override;
45 int WriteInternal(const void* pBuffer, size_t iBytes) override;
46 int FlushInternal() override;
47 int SeekInternal(int offset) override;
48 RageFileObjDirect* Copy() const override;
49 std::string GetDisplayPath() const override { return m_sPath; }
50 int GetFileSize() const override;
51 int GetFD() override;
52
53 private:
54 bool FinalFlush();
55
56 int m_iFD;
57 int m_iMode;
58 std::string m_sPath; /* for Copy */
59
60 /*
61 * When not streaming to disk, we write to a temporary file, and rename to
62 * the real file on completion. If any write, this is aborted. When
63 * streaming to disk, allow recovering from errors.
64 */
65 bool m_bWriteFailed;
66 bool WriteFailed() const
67 {
68 return ((m_iMode & RageFile::STREAMED) == 0) && m_bWriteFailed;
69 }
70
71 // unused
72 RageFileObjDirect& operator=(const RageFileObjDirect& rhs) = delete;
73 RageFileObjDirect(const RageFileObjDirect& rhs) = delete;
74};
75
76#endif
Definition RageFileBasic.h:10
Definition RageFileDriverDirect.h:26
File driver for accessing a regular filesystem.
Definition RageFileDriverDirect.h:9
Definition RageFileDriver.h:12
This driver handles direct file access.
Definition RageFileDriverDirect.h:40
Definition RageFileBasic.h:66