ezEngine  Milestone 7
DataDirType.h
1 #pragma once
2 
3 #include <Foundation/Basics.h>
4 #include <Foundation/Strings/String.h>
5 
9 
17 class EZ_FOUNDATION_DLL ezDataDirectoryType
18 {
19  EZ_DISALLOW_COPY_AND_ASSIGN(ezDataDirectoryType);
20 
21 public:
23  virtual ~ezDataDirectoryType() { }
24 
26  const ezString128& GetDataDirectoryPath() const { return m_sDataDirectoryPath; }
27 
31  virtual void ReloadExternalConfigs() { };
32 
33 protected:
34  friend class ezFileSystem;
35 
37  ezResult InitializeDataDirectory(const char* szDataDirPath);
38 
40  virtual ezDataDirectoryReader* OpenFileToRead(const char* szFile) = 0;
41 
45  virtual ezDataDirectoryWriter* OpenFileToWrite(const char* szFile) { return nullptr; }
46 
50  virtual void RemoveDataDirectory() = 0;
51 
53  virtual void DeleteFile(const char* szFile) { }
54 
59  virtual bool ExistsFile(const char* szFile);
60 
61 private:
63 
69 
74  virtual ezResult InternalInitializeDataDirectory(const char* szDirectory) = 0;
75 
78 };
79 
80 
81 
85 class EZ_FOUNDATION_DLL ezDataDirectoryReaderWriterBase
86 {
87  EZ_DISALLOW_COPY_AND_ASSIGN(ezDataDirectoryReaderWriterBase);
88 
89 public:
91  ezDataDirectoryReaderWriterBase(bool bIsReader);
92 
93  virtual ~ezDataDirectoryReaderWriterBase() { }
94 
96  ezResult Open(const char* szFilePath, ezDataDirectoryType* pOwnerDataDirectory);
97 
99  void Close();
100 
102  const ezString128& GetFilePath() const;
103 
105  ezDataDirectoryType* GetDataDirectory() const;
106 
108  bool IsReader() const { return m_bIsReader; }
109 
111  virtual ezUInt64 GetFileSize() const = 0;
112 
113 private:
115  virtual ezResult InternalOpen() = 0;
116 
118  virtual void InternalClose() = 0;
119 
120  bool m_bIsReader;
121  ezDataDirectoryType* m_pDataDirectory;
122  ezString128 m_sFilePath;
123 };
124 
129 {
130  EZ_DISALLOW_COPY_AND_ASSIGN(ezDataDirectoryReader);
131 
132 public:
134 
135  virtual ezUInt64 Read(void* pBuffer, ezUInt64 uiBytes) = 0;
136 };
137 
142 {
143  EZ_DISALLOW_COPY_AND_ASSIGN(ezDataDirectoryWriter);
144 
145 public:
147 
148  virtual ezResult Write(const void* pBuffer, ezUInt64 uiBytes) = 0;
149 };
150 
151 
152 #include <Foundation/IO/FileSystem/Implementation/DataDirType_inl.h>
153