GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
AbstractFileSystem.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 
7 #ifndef GDCORE_ABSTRACTFILESYSTEM
8 #define GDCORE_ABSTRACTFILESYSTEM
9 #include <vector>
10 #include "GDCore/String.h"
11 
12 #undef CopyFile // Remove a Windows macro
13 
14 namespace gd {
15 
24 class GD_CORE_API AbstractFileSystem {
25  public:
26  virtual ~AbstractFileSystem();
27 
39  static gd::String NormalizeSeparator(gd::String filename);
40 
45  virtual void MkDir(const gd::String& path) = 0;
46 
50  virtual bool DirExists(const gd::String& path) = 0;
51 
55  virtual bool FileExists(const gd::String& path) = 0;
56 
60  virtual bool ClearDir(const gd::String& directory) = 0;
61 
65  virtual gd::String GetTempDir() = 0;
66 
70  virtual gd::String FileNameFrom(const gd::String& file) = 0;
71 
75  virtual gd::String DirNameFrom(const gd::String& file) = 0;
76 
81  virtual bool MakeAbsolute(gd::String& filename,
82  const gd::String& baseDirectory) = 0;
83 
87  virtual bool IsAbsolute(const gd::String& filename) = 0;
88 
93  virtual bool MakeRelative(gd::String& filename,
94  const gd::String& baseDirectory) = 0;
95 
100  virtual bool CopyFile(const gd::String& file,
101  const gd::String& destination) = 0;
102 
107  virtual bool WriteToFile(const gd::String& file,
108  const gd::String& content) = 0;
109 
114  virtual gd::String ReadFile(const gd::String& file) = 0;
115 
123  virtual std::vector<gd::String> ReadDir(const gd::String& path,
124  const gd::String& extension = "") = 0;
125 
126  protected:
127  AbstractFileSystem(){};
128 };
129 
130 } // namespace gd
131 
132 #endif // GDCORE_ABSTRACTFILESYSTEM
An interface to manipulate files in a platform agnostic way. This allow exporters to work on files wi...
Definition: AbstractFileSystem.h:24
virtual bool MakeAbsolute(gd::String &filename, const gd::String &baseDirectory)=0
Change the filename so that it is absolute, using the base directory passed as parameter.
virtual gd::String DirNameFrom(const gd::String &file)=0
Extract the path without the filename.
virtual bool DirExists(const gd::String &path)=0
Return true if the specified directory exists.
virtual std::vector< gd::String > ReadDir(const gd::String &path, const gd::String &extension="")=0
Return a vector containing the files in the specified path.
virtual bool MakeRelative(gd::String &filename, const gd::String &baseDirectory)=0
Change the filename so that it is relative to the base directory passed as parameter.
virtual bool WriteToFile(const gd::String &file, const gd::String &content)=0
Write the content of a string to a file.
virtual gd::String FileNameFrom(const gd::String &file)=0
Extract the name of the file (with its extension) from a path.
virtual bool FileExists(const gd::String &path)=0
Return true if the specified file exists.
virtual gd::String ReadFile(const gd::String &file)=0
Read the content of a file.
virtual gd::String GetTempDir()=0
Get a directory suitable for temporary files.
virtual bool IsAbsolute(const gd::String &filename)=0
Return true if the filename is absolute.
virtual void MkDir(const gd::String &path)=0
Create the specified directory.
virtual bool ClearDir(const gd::String &directory)=0
Clear the directory given as parameter, removing all the files.
virtual bool CopyFile(const gd::String &file, const gd::String &destination)=0
Copy a file.
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24