TDME2  1.9.200
StandardFileSystem.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
10 
11 using std::string;
12 using std::vector;
13 
16 
17 /**
18  * Standard file system implementation
19  * @author Andreas Drewke
20  */
22 {
23 
24 public:
25  // forbid class copy
27 
28  /**
29  * Public constructor
30  */
32 
33  /**
34  * Public destructor
35  */
37 
38  // overridden methods
39  const string composeURI(const string& pathName, const string& fileName);
40  uint64_t getFileSize(const string& pathName, const string& fileName);
41  const string getContentAsString(const string& pathName, const string& fileName);
42  void setContentFromString(const string& pathName, const string& fileName, const string& content);
43  void getContent(const string& pathName, const string& fileName, vector<uint8_t>& content);
44  void setContent(const string& pathName, const string& fileName, const vector<uint8_t>& content);
45  void getContentAsStringArray(const string& pathName, const string& fileName, vector<string>& content);
46  void setContentFromStringArray(const string& pathName, const string& fileName, const vector<string>& content);
47  void list(const string& pathName, vector<string>& files, FileNameFilter* filter = nullptr, bool addDrives = false);
48  bool isPath(const string& uri);
49  bool isDrive(const string& uri);
50  bool exists(const string& uri);
51  bool isExecutable(const string& pathName, const string& fileName) override;
52  void setExecutable(const string& pathName, const string& fileName) override;
53  const string getCanonicalURI(const string& pathName, const string& fileName);
54  const string getCurrentWorkingPathName();
55  void changePath(const string& pathName);
56  const string getPathName(const string& uri);
57  const string getFileName(const string& uri);
58  const string removeFileExtension(const string& fileName);
59  void createPath(const string& pathName);
60  void removePath(const string& pathName, bool recursive);
61  void removeFile(const string& pathName, const string& fileName);
62  void rename(const string& fileNameFrom, const string& fileNameTo);
63  bool getThumbnailAttachment(const string& pathName, const string& fileName, vector<uint8_t>& thumbnailAttachmentContent);
64  bool getThumbnailAttachment(const vector<uint8_t>& content, vector<uint8_t>& thumbnailAttachmentContent);
65 };
Standard file system implementation.
const string removeFileExtension(const string &fileName)
Remove file extension, e.g.
bool isDrive(const string &uri)
Check if file is a drive (applies to Microsoft Windows only)
void setContentFromString(const string &pathName, const string &fileName, const string &content)
Set content from string.
const string composeURI(const string &pathName, const string &fileName)
Compose URI from path name and file name.
const string getPathName(const string &uri)
Get path name.
const string getCanonicalURI(const string &pathName, const string &fileName)
Get canonical URI from given path name and file name.
void createPath(const string &pathName)
Create path.
bool getThumbnailAttachment(const string &pathName, const string &fileName, vector< uint8_t > &thumbnailAttachmentContent)
Reads a thumbnail attachment from binary file.
void list(const string &pathName, vector< string > &files, FileNameFilter *filter=nullptr, bool addDrives=false)
List files for given path and filter by a file name filter if not null.
void changePath(const string &pathName)
Change path.
void removePath(const string &pathName, bool recursive)
Remove path.
void setExecutable(const string &pathName, const string &fileName) override
Set up file to be an executable file.
void setContent(const string &pathName, const string &fileName, const vector< uint8_t > &content)
Set file content.
void getContent(const string &pathName, const string &fileName, vector< uint8_t > &content)
Get file content.
void setContentFromStringArray(const string &pathName, const string &fileName, const vector< string > &content)
Set file content as string array.
void removeFile(const string &pathName, const string &fileName)
Remove file.
uint64_t getFileSize(const string &pathName, const string &fileName)
Return file size of given file.
void getContentAsStringArray(const string &pathName, const string &fileName, vector< string > &content)
Get file content as string array.
const string getFileName(const string &uri)
Get file name.
bool isPath(const string &uri)
Check if file is a path.
bool exists(const string &uri)
Check if file exists.
const string getCurrentWorkingPathName()
Get current working path name.
bool isExecutable(const string &pathName, const string &fileName) override
Returns if file is a executable file.
const string getContentAsString(const string &pathName, const string &fileName)
Get content as string.
void rename(const string &fileNameFrom, const string &fileNameTo)
Rename file.
File system file name filter interface.
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6