distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
FileSystem.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_FILESYSTEM_FILESYSTEM_HPP_
13 #define INCLUDE_DISTORTOS_FILESYSTEM_FILESYSTEM_HPP_
14 
17 
18 #include <sys/statvfs.h>
19 
20 #include <memory>
21 
22 namespace distortos
23 {
24 
25 class Directory;
26 class File;
27 
35 {
36 public:
37 
44  virtual ~FileSystem() = default;
45 
54  virtual int format() = 0;
55 
73  virtual int getFileStatus(const char* path, struct stat& status) = 0;
74 
87  virtual int getStatus(struct statvfs& status) = 0;
88 
104  virtual void lock() = 0;
105 
126  virtual int makeDirectory(const char* path, mode_t mode) = 0;
127 
138  virtual int mount() = 0;
139 
158  virtual std::pair<int, std::unique_ptr<Directory>> openDirectory(const char* path) = 0;
159 
188  virtual std::pair<int, std::unique_ptr<File>> openFile(const char* path, int flags) = 0;
189 
208  virtual int remove(const char* path) = 0;
209 
233  virtual int rename(const char* path, const char* newPath) = 0;
234 
245  virtual void unlock() = 0;
246 
259  virtual int unmount() = 0;
260 
261  FileSystem() = default;
262  FileSystem(const FileSystem&) = delete;
263  FileSystem& operator=(const FileSystem&) = delete;
264 };
265 
266 } // namespace distortos
267 
268 #endif // INCLUDE_DISTORTOS_FILESYSTEM_FILESYSTEM_HPP_
Standard sys/statvfs.h, which is not provided by newlib.
virtual int unmount()=0
Unmounts file system from associated device.
virtual void lock()=0
Locks the file system for exclusive use by current thread.
virtual void unlock()=0
Unlocks the file system which was previously locked by current thread.
File class header.
Directory class header.
virtual int format()=0
Formats associated device with the file system.
virtual int mount()=0
Mounts file system on associated device.
Top-level namespace of distortos project.
Definition: buttons.hpp:33
virtual int getFileStatus(const char *path, struct stat &status)=0
Returns status of file.
virtual std::pair< int, std::unique_ptr< Directory > > openDirectory(const char *path)=0
Opens directory.
virtual ~FileSystem()=default
FileSystem's destructor.
Definition: statvfs.h:56
Definition: FileSystem.hpp:34
virtual int remove(const char *path)=0
Removes file or directory.
virtual std::pair< int, std::unique_ptr< File > > openFile(const char *path, int flags)=0
Opens file.
virtual int getStatus(struct statvfs &status)=0
Returns status of file system.
virtual int rename(const char *path, const char *newPath)=0
Renames file or directory.
virtual int makeDirectory(const char *path, mode_t mode)=0
Makes a directory.