Components/IFS/src/include/IFS/Gdb/FileSystem.h
Go to the documentation of this file.
1 /****
2  * FileSystem.h
3  * IFS wrapper for GDB syscall file access
4  *
5  * Created on: 1 December 2020
6  *
7  * Copyright 2019 mikee47 <mike@sillyhouse.net>
8  *
9  * This file is part of the IFS Library
10  *
11  * This library is free software: you can redistribute it and/or modify it under the terms of the
12  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with this library.
19  * If not, see <https://www.gnu.org/licenses/>.
20  *
21  ****/
22 
23 #pragma once
24 
25 #include "../IFileSystem.h"
26 
27 namespace IFS::Gdb
28 {
32 class FileSystem : public IFileSystem
33 {
34 public:
35  FileSystem() = default;
36 
37  ~FileSystem() override = default;
38 
39  int mount() override
40  {
41  return FS_OK;
42  }
43 
44  // IFileSystem methods
45  int getinfo(Info& info) override;
46  String getErrorString(int err) override;
47  int opendir(const char*, DirHandle&) override
48  {
49  return Error::NotSupported;
50  }
51  int rewinddir(DirHandle) override
52  {
53  return Error::NotSupported;
54  }
55  int readdir(DirHandle, Stat&) override
56  {
57  return Error::NotSupported;
58  }
59  int closedir(DirHandle) override
60  {
61  return Error::NotSupported;
62  }
63  int mkdir(const char*) override
64  {
65  return Error::NotSupported;
66  }
67  int stat(const char* path, Stat* stat) override;
68  int fstat(FileHandle file, Stat* stat) override;
69  int fsetxattr(FileHandle, AttributeTag, const void*, size_t) override
70  {
71  return Error::NotSupported;
72  }
73  int fgetxattr(FileHandle, AttributeTag, void*, size_t) override
74  {
75  return Error::NotSupported;
76  }
77  int fenumxattr(FileHandle, AttributeEnumCallback, void*, size_t) override
78  {
79  return Error::NotSupported;
80  }
81  int setxattr(const char*, AttributeTag, const void*, size_t) override
82  {
83  return Error::NotSupported;
84  }
85  int getxattr(const char*, AttributeTag, void*, size_t) override
86  {
87  return Error::NotSupported;
88  }
89  FileHandle open(const char* path, OpenFlags flags) override;
90  int close(FileHandle file) override;
91  int read(FileHandle file, void* data, size_t size) override;
92  int write(FileHandle file, const void* data, size_t size) override;
93  file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override;
94  int eof(FileHandle file) override;
95  file_offset_t tell(FileHandle file) override;
97  {
98  return Error::NotSupported;
99  }
100  int flush(FileHandle) override
101  {
102  return Error::NotSupported;
103  }
104  int rename(const char* oldpath, const char* newpath) override;
105  int remove(const char* path) override;
106  int fremove(FileHandle) override
107  {
108  return Error::NotImplemented;
109  }
110  int format() override
111  {
112  return Error::NotSupported;
113  }
114  int check() override
115  {
116  return FS_OK;
117  }
118 };
119 
120 } // namespace IFS::Gdb
int32_t file_offset_t
Definition: Components/IFS/src/include/IFS/Types.h:49
uint32_t file_size_t
Definition: Components/IFS/src/include/IFS/Types.h:48
SeekOrigin
Stream/file seek origins.
Definition: SeekOrigin.h:18
Manage a set of bit values using enumeration.
Definition: BitSet.h:45
Delegate class, encapsulates a std::function Added constructor template implements lambda callback wh...
Definition: Delegate.h:24
IFS implementation of Host filing system.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:33
int getxattr(const char *, AttributeTag, void *, size_t) override
Get an attribute from a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:85
int getinfo(Info &info) override
get filing system information
~FileSystem() override=default
int fgetxattr(FileHandle, AttributeTag, void *, size_t) override
Get an extended attribute from an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:73
int stat(const char *path, Stat *stat) override
get file information
int fenumxattr(FileHandle, AttributeEnumCallback, void *, size_t) override
Enumerate attributes.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:77
int fstat(FileHandle file, Stat *stat) override
get file information
int readdir(DirHandle, Stat &) override
read a directory entry
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:55
int mkdir(const char *) override
Create a directory.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:63
FileHandle open(const char *path, OpenFlags flags) override
open a file (or directory) by path
int opendir(const char *, DirHandle &) override
open a directory for reading
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:47
int ftruncate(FileHandle, file_size_t) override
Truncate (reduce) the size of an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:96
int setxattr(const char *, AttributeTag, const void *, size_t) override
Set an extended attribute for a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:81
String getErrorString(int err) override
get the text for a returned error code
int closedir(DirHandle) override
close a directory object
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:59
int fsetxattr(FileHandle, AttributeTag, const void *, size_t) override
Set an extended attribute on an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:69
int format() override
format the filing system
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:110
int check() override
Perform a file system consistency check.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:114
int write(FileHandle file, const void *data, size_t size) override
write content to a file at current position and advance cursor
int fremove(FileHandle) override
remove (delete) a file by handle
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:106
int close(FileHandle file) override
close an open file
int read(FileHandle file, void *data, size_t size) override
read content from a file and advance cursor
int rewinddir(DirHandle) override
Reset directory read position to start.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:51
int remove(const char *path) override
remove (delete) a file by path
int flush(FileHandle) override
flush any buffered data to physical media
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:100
file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override
change file read/write position
int rename(const char *oldpath, const char *newpath) override
rename a file
int eof(FileHandle file) override
determine if current file position is at end of file
int mount() override
Mount file system, performing any required initialisation.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:39
file_offset_t tell(FileHandle file) override
get current file position
Installable File System base class.
Definition: IFileSystem.h:99
The String class.
Definition: WString.h:133
constexpr ErrorCode FS_OK
Definition: Components/IFS/src/include/IFS/Error.h:130
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:28
struct ImplFileDir * DirHandle
Definition: IFileSystem.h:72
AttributeTag
Identifies a specific attribute.
Definition: Attribute.h:45
int16_t FileHandle
File handle.
Definition: Stat.h:40
Basic information about filing system.
Definition: IFileSystem.h:121
File Status structure.
Definition: Stat.h:52