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
28 {
29 namespace Gdb
30 {
34 class FileSystem : public IFileSystem
35 {
36 public:
37  FileSystem()
38  {
39  }
40 
41  ~FileSystem() override
42  {
43  }
44 
45  int mount() override
46  {
47  return FS_OK;
48  }
49 
50  // IFileSystem methods
51  int getinfo(Info& info) override;
52  String getErrorString(int err) override;
53  int opendir(const char* path, DirHandle& dir) override
54  {
55  return Error::NotSupported;
56  }
57  int rewinddir(DirHandle dir) override
58  {
59  return Error::NotSupported;
60  }
61  int readdir(DirHandle dir, Stat& stat) override
62  {
63  return Error::NotSupported;
64  }
65  int closedir(DirHandle dir) override
66  {
67  return Error::NotSupported;
68  }
69  int mkdir(const char* path) override
70  {
71  return Error::NotSupported;
72  }
73  int stat(const char* path, Stat* stat) override;
74  int fstat(FileHandle file, Stat* stat) override;
75  int fsetxattr(FileHandle file, AttributeTag tag, const void* data, size_t size) override
76  {
77  return Error::NotSupported;
78  }
79  int fgetxattr(FileHandle file, AttributeTag tag, void* buffer, size_t size) override
80  {
81  return Error::NotSupported;
82  }
83  int fenumxattr(FileHandle file, AttributeEnumCallback callback, void* buffer, size_t bufsize) override
84  {
85  return Error::NotSupported;
86  }
87  int setxattr(const char* path, AttributeTag tag, const void* data, size_t size) override
88  {
89  return Error::NotSupported;
90  }
91  int getxattr(const char* path, AttributeTag tag, void* buffer, size_t size) override
92  {
93  return Error::NotSupported;
94  }
95  FileHandle open(const char* path, OpenFlags flags) override;
96  int close(FileHandle file) override;
97  int read(FileHandle file, void* data, size_t size) override;
98  int write(FileHandle file, const void* data, size_t size) override;
99  file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override;
100  int eof(FileHandle file) override;
101  file_offset_t tell(FileHandle file) override;
102  int ftruncate(FileHandle file, file_size_t new_size) override
103  {
104  return Error::NotSupported;
105  }
106  int flush(FileHandle file) override
107  {
108  return Error::NotSupported;
109  }
110  int rename(const char* oldpath, const char* newpath) override;
111  int remove(const char* path) override;
112  int fremove(FileHandle file) override
113  {
114  return Error::NotImplemented;
115  }
116  int format() override
117  {
118  return Error::NotSupported;
119  }
120  int check() override
121  {
122  return FS_OK;
123  }
124 };
125 
126 } // namespace Gdb
127 } // namespace IFS
int getxattr(const char *path, AttributeTag tag, void *buffer, size_t size) override
Get an attribute from a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:151
int stat(const char *path, Stat *stat) override
get file information
file_offset_t lseek(FileHandle file, file_offset_t offset, SeekOrigin origin) override
change file read/write position
The String class.
Definition: WString.h:136
int mkdir(const char *path) override
Create a directory.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:129
constexpr ErrorCode FS_OK
Definition: Components/IFS/src/include/IFS/Error.h:130
int getinfo(Info &info) override
get filing system information
int eof(FileHandle file) override
determine if current file position is at end of file
int check() override
Perform a file system consistency check.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:180
BitSet< uint8_t, OpenFlag, size_t(OpenFlag::MAX)> OpenFlags
Definition: OpenFlags.h:69
int read(FileHandle file, void *data, size_t size) override
read content from a file and advance cursor
int16_t FileHandle
File handle.
Definition: Stat.h:59
~FileSystem() override
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:101
int rewinddir(DirHandle dir) override
Reset directory read position to start.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:117
Definition: DirectoryTemplate.h:36
FileHandle open(const char *path, OpenFlags flags) override
open a file (or directory) by path
int mount() override
Mount file system, performing any required initialisation.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:105
int32_t file_offset_t
Definition: Components/IFS/src/include/IFS/Types.h:51
int close(FileHandle file) override
close an open file
int fenumxattr(FileHandle file, AttributeEnumCallback callback, void *buffer, size_t bufsize) override
Enumerate attributes.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:143
File Status structure.
Definition: Stat.h:71
int fstat(FileHandle file, Stat *stat) override
get file information
int flush(FileHandle file) override
flush any buffered data to physical media
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:166
struct ImplFileDir * DirHandle
Definition: IFileSystem.h:72
FileSystem()
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:97
int fremove(FileHandle file) override
remove (delete) a file by handle
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:172
AttributeTag
Identifies a specific attribute.
Definition: Attribute.h:64
IFS::FileHandle FileHandle
Definition: Core/FileSystem.h:24
int format() override
format the filing system
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:176
SeekOrigin
Stream/file seek origins.
Definition: SeekOrigin.h:18
int fgetxattr(FileHandle file, AttributeTag tag, void *buffer, size_t size) override
Get an extended attribute from an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:139
int remove(const char *path) override
remove (delete) a file by path
int fsetxattr(FileHandle file, AttributeTag tag, const void *data, size_t size) override
Set an extended attribute on an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:135
int write(FileHandle file, const void *data, size_t size) override
write content to a file at current position and advance cursor
int setxattr(const char *path, AttributeTag tag, const void *data, size_t size) override
Set an extended attribute for a file given its path.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:147
int opendir(const char *path, DirHandle &dir) override
open a directory for reading
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:113
IFS::DirHandle DirHandle
Definition: Core/FileSystem.h:25
Definition: Delegate.h:20
file_offset_t tell(FileHandle file) override
get current file position
int rename(const char *oldpath, const char *newpath) override
rename a file
String getErrorString(int err) override
get the text for a returned error code
int closedir(DirHandle dir) override
close a directory object
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:125
uint32_t file_size_t
Definition: Components/IFS/src/include/IFS/Types.h:50
int ftruncate(FileHandle file, file_size_t new_size) override
Truncate (reduce) the size of an open file.
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:162
int readdir(DirHandle dir, Stat &stat) override
read a directory entry
Definition: Components/IFS/src/include/IFS/Gdb/FileSystem.h:121