ezEngine  Milestone 7
DataDirTypeFolder.h
1 #pragma once
2 
3 #include <Foundation/IO/FileSystem/Implementation/DataDirType.h>
4 #include <Foundation/IO/OSFile.h>
5 #include <Foundation/Containers/HybridArray.h>
6 #include <Foundation/Containers/Map.h>
7 
8 namespace ezDataDirectory
9 {
10  class FolderReader;
11  class FolderWriter;
12 
16  class EZ_FOUNDATION_DLL FolderType : public ezDataDirectoryType
17  {
18  public:
19  ~FolderType();
20 
22  static ezDataDirectoryType* Factory(const char* szDataDirectory);
23 
31 
34 
35  virtual void ReloadExternalConfigs() override;
36 
37  protected:
38  // The implementations of the abstract functions.
39 
40  virtual ezDataDirectoryReader* OpenFileToRead(const char* szFile) override;
41  virtual ezDataDirectoryWriter* OpenFileToWrite(const char* szFile) override;
42  virtual void RemoveDataDirectory() override;
43  virtual void DeleteFile(const char* szFile) override;
44 
45  private:
47  virtual ezResult InternalInitializeDataDirectory(const char* szDirectory) override;
48 
50  virtual void OnReaderWriterClose(ezDataDirectoryReaderWriterBase* pClosed) override;
51 
52  void LoadRedirectionFile();
53 
56 
57  ezMap<ezString, ezString> m_FileRedirection;
58  };
59 
60 
62  class EZ_FOUNDATION_DLL FolderReader : public ezDataDirectoryReader
63  {
64  EZ_DISALLOW_COPY_AND_ASSIGN(FolderReader);
65 
66  public:
67  FolderReader() { m_bIsInUse = false; }
68  virtual ezUInt64 Read(void* pBuffer, ezUInt64 uiBytes) override;
69  virtual ezUInt64 GetFileSize() const override;
70 
71  private:
72  virtual ezResult InternalOpen() override;
73  virtual void InternalClose() override;
74 
75  friend class FolderType;
76 
77  bool m_bIsInUse;
78  ezOSFile m_File;
79  };
80 
82  class EZ_FOUNDATION_DLL FolderWriter : public ezDataDirectoryWriter
83  {
84  EZ_DISALLOW_COPY_AND_ASSIGN(FolderWriter);
85 
86  public:
87  FolderWriter() { m_bIsInUse = false; }
88  virtual ezResult Write(const void* pBuffer, ezUInt64 uiBytes) override;
89  virtual ezUInt64 GetFileSize() const override;
90 
91  private:
92  virtual ezResult InternalOpen() override;
93  virtual void InternalClose() override;
94 
95  friend class FolderType;
96 
97  bool m_bIsInUse;
98  ezOSFile m_File;
99  };
100 
101 }
102 
103 
104