Oxygine  1
2g game engine
FileSystem.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Object.h"
4 
5 namespace oxygine
6 {
7  namespace file
8  {
9  class buffer;
10  class FileSystem;
11 
12  class fileHandle: public ObjectBase
13  {
14  public:
15  fileHandle(FileSystem* fs): _fs(fs) {}
16  virtual void release() = 0;
17  virtual unsigned int read(void* dest, unsigned int size) = 0;
18  virtual unsigned int write(const void* src, unsigned int size) = 0;
19  virtual unsigned int getSize() const = 0;
20  virtual int seek(unsigned int offset, int whence) = 0;
21  virtual unsigned int tell() const = 0;
22 
23  FileSystem* _fs;
24  };
25 
26 
27  class FileSystem
28  {
29  public:
30  enum status
31  {
32  //don't add new items (isExists will be broken)
33  status_error,
34  status_ok,
35  };
36 
37  FileSystem(bool readonly);
38  virtual ~FileSystem();
39 
40  void setPrefix(const char* str);
41 
42  bool isExists(const char* file);
43  bool isExistsHere(const char* file);
44 
45  status deleteFile(const char* file);
46  status renameFile(const char* src, const char* dest);
47  status makeDirectory(const char* path);
48  status deleteDirectory(const char* path);
49 
50  status open(const char* file, const char* mode, error_policy ep, fileHandle*& fh);
51  status read(const char* file, file::buffer& bf, error_policy ep);
52 
53  void mount(FileSystem* fs);
54  void unmount(FileSystem* fs);
55 
56  protected:
57  virtual status _open(const char* file, const char* mode, error_policy ep, fileHandle*&) = 0;
58  virtual status _read(const char* file, file::buffer&, error_policy ep) = 0;
59  virtual bool _isExists(const char* file);
60  virtual status _deleteFile(const char* file) = 0;
61  virtual status _makeDirectory(const char* path) = 0;
62  virtual status _deleteDirectory(const char* path) = 0;
63  virtual status _renameFile(const char* src, const char* dest) = 0;
64 
65  char _prefix[32];
66  bool _readonly;
67 
68  typedef std::vector<FileSystem*> filesystems;
69  filesystems _filesystems;
70  };
71 
72  void mount(FileSystem* fs);
73  void unmount(FileSystem* fs);
74  }
75 }
Definition: Object.h:19
Definition: FileSystem.h:12
–oxgl-end–!
Definition: Actor.h:14
Definition: file.h:18
Definition: FileSystem.h:27