My Project
FileManager.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2004 - 2006 ParaEngine Dev Studio, All Rights Reserved.
3 // Date: 2005.3
4 // Description: API for File IO in ParaEngine
5 //-----------------------------------------------------------------------------
6 #pragma once
7 #include "FileHandle.h"
8 #include "FilePath.h"
9 #include "FileSearchResult.h"
10 #include "ParaFile.h"
11 
12 #if defined(PARAENGINE_MOBILE)
13  #define USE_COCOS_FILE_API
14 #else
15  #if !defined(WIN32) || !defined(PARAENGINE_CLIENT) // || defined(_DEBUG)
16  #define USE_BOOST_FILE_API
17  #endif
18 #endif
19 
20 namespace ParaEngine
21 {
22  using namespace std;
23  class CArchive;
24  class CParaFile;
25  class CSearchResult;
26  class BlockReadWriteLock;
27 
33  {
34  public:
35  CFileManager(void);
36  virtual ~CFileManager(void);
37 
38  ATTRIBUTE_DEFINE_CLASS(CFileManager);
39  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
40 
42  virtual IAttributeFields* GetChildAttributeObject(const std::string& sName);
44  virtual int GetChildAttributeObjectCount(int nColumnIndex = 0);
45  virtual IAttributeFields* GetChildAttributeObject(int nRowIndex, int nColumnIndex = 0);
46 
47 
49  PE_CORE_DECL static CFileManager * GetInstance();
50  public:
51 
56  PE_CORE_DECL bool OpenArchive(const string& path, bool bUseRelativePath=false);
57 
63  PE_CORE_DECL bool OpenArchiveEx(const string& path, const string& sRootDir);
64 
67  PE_CORE_DECL void CloseArchive(const string& path);
68 
70  PE_CORE_DECL CArchive* GetArchive(const string& path);
71 
79  PE_CORE_DECL void LoadFile(CParaFile* pFile, const char* fileName);
80 
81 
83  PE_CORE_DECL bool OpenFile(const char* filename, FileHandle& handle);
84 
86  PE_CORE_DECL DWORD GetFileSize(FileHandle& handle);
87 
89  PE_CORE_DECL bool ReadFile(FileHandle& handle,LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead);
90 
97  PE_CORE_DECL bool ReadFileRaw(FileHandle& handle,LPVOID* lppBuffer,LPDWORD pnCompressedSize, LPDWORD pnUncompressedSize);
98 
100  PE_CORE_DECL bool CloseFile(FileHandle& hFile);
101 
112  PE_CORE_DECL CSearchResult* SearchFiles(const string& sRootPath, const string& sFilePattern, const string& sZipArchive, int nSubLevel=0, int nMaxFilesNum=50, int nFrom=0);
113 
118  PE_CORE_DECL bool DoesFileExist(const char* filename);
119 
120  protected:
122  list <CArchive*> m_archivers;
123  int m_priority;
124  BlockReadWriteLock* m_pArchiveLock;
125  private:
127  static void FindDiskFiles(CSearchResult& result, const string& sRootPath, const string& sFilePattern, int nSubLevel);
128 
129  friend class CParaFile;
130  };
131 }
file archiver base class.
Definition: Archive.h:24
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
a file handle in a Archive
Definition: FileHandle.h:13
this is the main file interface exposed by ParaEngine.
Definition: FileManager.h:32
Definition: handle.hpp:33
different physics engine has different winding order.
Definition: EventBinding.h:32
search path manager interface and implementation.
Definition: FilePath.h:106
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
multiple shared readers and multiple exclusive writers it favors writers over readers.
Definition: BlockReadWriteLock.h:18
list< CArchive * > m_archivers
a list of all archives
Definition: FileManager.h:122
it represents the search result.
Definition: FileSearchResult.h:24