Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h
Go to the documentation of this file.
1 
23 #pragma once
24 
25 #include <IFS/IFileSystem.h>
26 
27 struct stat;
28 
29 namespace IFS
30 {
31 namespace Host
32 {
36 class FileSystem : public IFileSystem
37 {
38 public:
40  {
41  }
42 
43  ~FileSystem() override
44  {
45  }
46 
47  int mount() override
48  {
49  return FS_OK;
50  }
51 
52  // IFileSystem methods
53  int getinfo(Info& info) override;
54  String getErrorString(int err) override;
55  int opendir(const char* path, DirHandle& dir) override;
56  int rewinddir(DirHandle dir) override;
57  int readdir(DirHandle dir, Stat& stat) override;
58  int closedir(DirHandle dir) override;
59  int mkdir(const char* path) override;
60  int stat(const char* path, Stat* stat) override;
61  int fstat(FileHandle file, Stat* stat) override;
62  int setacl(FileHandle file, const ACL& acl) override;
63  int setattr(const char* path, FileAttributes attr) override;
64  int settime(FileHandle file, time_t mtime) override;
65  int setcompression(FileHandle file, const Compression& compression) override;
66  FileHandle open(const char* path, OpenFlags flags) override;
67  FileHandle fopen(const Stat& stat, OpenFlags flags) override;
68  int close(FileHandle file) override;
69  int read(FileHandle file, void* data, size_t size) override;
70  int write(FileHandle file, const void* data, size_t size) override;
71  int lseek(FileHandle file, int offset, SeekOrigin origin) override;
72  int eof(FileHandle file) override;
73  int32_t tell(FileHandle file) override;
74  int ftruncate(FileHandle file, size_t new_size) override;
75  int flush(FileHandle file) override
76  {
77  return Error::ReadOnly;
78  }
79  int rename(const char* oldpath, const char* newpath) override
80  {
81  return Error::ReadOnly;
82  }
83  int remove(const char* path) override
84  {
85  return Error::ReadOnly;
86  }
87  int fremove(FileHandle file) override
88  {
89  return Error::ReadOnly;
90  }
91  int format() override
92  {
93  return Error::ReadOnly;
94  }
95  int check() override
96  {
97  return Error::NotImplemented;
98  }
99 
100 private:
101  void fillStat(const struct stat& s, Stat& stat);
102 };
103 
104 } // namespace Host
105 } // namespace IFS
Basic information about filing system.
Definition: IFileSystem.h:123
struct FileDir * DirHandle
Definition: IFileSystem.h:65
int setacl(FileHandle file, const ACL &acl) override
Set access control information for file.
FileSystem()
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:39
int flush(FileHandle file) override
flush any buffered data to physical media
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:75
int readdir(DirHandle dir, Stat &stat) override
read a directory entry
int check() override
Perform a file system consistency check.
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:95
Installable File System base class.
Definition: IFileSystem.h:100
int rewinddir(DirHandle dir) override
Reset directory read position to start.
int lseek(FileHandle file, int offset, SeekOrigin origin) override
change file read/write position
int ftruncate(FileHandle file, size_t new_size) override
Truncate (reduce) the size of an open file.
int write(FileHandle file, const void *data, size_t size) override
write content to a file at current position and advance cursor
FileHandle fopen(const Stat &stat, OpenFlags flags) override
open a file from it&#39;s stat structure
int fstat(FileHandle file, Stat *stat) override
get file information
int closedir(DirHandle dir) override
close a directory object
int setcompression(FileHandle file, const Compression &compression) override
Set file compression information.
The String class.
Definition: WString.h:136
int stat(const char *path, Stat *stat) override
get file information
FileHandle open(const char *path, OpenFlags flags) override
open a file by name/path
IFS implementation of Host filing system.
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:36
int32_t tell(FileHandle file) override
get current file position
SeekOrigin
Stream/file seek origins.
Definition: SeekOrigin.h:18
int close(FileHandle file) override
close an open file
int fremove(FileHandle file) override
remove (delete) a file by handle
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:87
int mkdir(const char *path) override
Create a directory.
int16_t FileHandle
File handle.
Definition: Stat.h:39
Definition: DirectoryTemplate.h:36
int opendir(const char *path, DirHandle &dir) override
open a directory for reading
int setattr(const char *path, FileAttributes attr) override
Set file attributes.
~FileSystem() override
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:43
int mount() override
Mount file system, performing any required initialisation.
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:47
int rename(const char *oldpath, const char *newpath) override
rename a file
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:79
int getinfo(Info &info) override
get filing system information
int read(FileHandle file, void *data, size_t size) override
read content from a file and advance cursor
File Status structure.
Definition: Stat.h:51
int settime(FileHandle file, time_t mtime) override
Set modificatino tiem for file.
String getErrorString(int err) override
get the text for a returned error code
int eof(FileHandle file) override
determine if current file position is at end of file
Definition: Access.h:34
int format() override
format the filing system
Definition: Components/IFS/src/Arch/Host/include/IFS/Host/FileSystem.h:91
constexpr ErrorCode FS_OK
Definition: Error.h:130
A compression descriptor.
Definition: Compression.h:38