Cafu Engine
FileSys.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_FILESYS_FILESYSTEM_HPP_INCLUDED
8 #define CAFU_FILESYS_FILESYSTEM_HPP_INCLUDED
9 
10 #include <string>
11 
12 
13 namespace cf
14 {
15  namespace FileSys
16  {
17  class InFileI;
18 
19 
20  /// A class for exceptions of the FileSystemT class.
21  /// This is mostly used when new FileSystemT objects are to be created, but the creation is not possible,
22  /// for example when a zip archive file cannot be opened, a local path doesn't exist, etc.
23  class FileSystemExceptionT : public std::exception
24  {
25  public:
26 
27  enum ReasonT
28  {
29  Generic,
30  InitFailure
31  };
32 
33 
34  /// The constructor.
35  FileSystemExceptionT(ReasonT R=Generic) : Reason(R) { }
36 
37  /// The reason for the exception.
38  ReasonT Reason;
39  };
40 
41 
43  {
44  public:
45 
46  /// The virtual destructor, so that derived classes can safely be deleted via a FileSystemT (base class) pointer.
47  virtual ~FileSystemT() { }
48 
49  /// Opens the file with the given name for reading.
50  /// @param FileName The name of the file to be opened within this file system.
51  /// @returns The pointer to the file or NULL if the file could not be opened.
52  virtual InFileI* OpenRead(const std::string& FileName)=0;
53  };
54  }
55 }
56 
57 #endif
FileSystemExceptionT(ReasonT R=Generic)
The constructor.
Definition: FileSys.hpp:35
Definition: File.hpp:55
ReasonT Reason
The reason for the exception.
Definition: FileSys.hpp:38
virtual ~FileSystemT()
The virtual destructor, so that derived classes can safely be deleted via a FileSystemT (base class) ...
Definition: FileSys.hpp:47
Definition: FileSys.hpp:42
A class for exceptions of the FileSystemT class.
Definition: FileSys.hpp:23
virtual InFileI * OpenRead(const std::string &FileName)=0
Opens the file with the given name for reading.