85 if (fs->name ==
nullptr)
90 size_t fs_name_len = strlen(fs->name);
91 if (fs_name_len > strlen(path))
96 if (strncmp(fs->name, path, fs_name_len))
101 if (path[fs_name_len] !=
'/' && strcmp(fs->name, path))
143 const char *subpath = path + strlen(fs->
name) + 1;
167 if (fd >=0 && fd <= 2)
196 const char *subpath = path + strlen(fs->
name) + 1;
197 int result = fs->
unlink(subpath);
221 const char *subpath = path + strlen(fs->
name) + 1;
222 int result = fs->
stat(subpath,
stat);
309 const char *subpath =
name + strlen(fs->
name) + 1;
DIR * opendir(const char *name)
Open a directory.
struct dirent * readdir(DIR *dirp)
Read the next entry in a directory.
int closedir(DIR *dirp)
Close a directory.
Base class for both Device and FileSystem objects.
static void fd_free(int fd)
Free up a file descriptor.
static File * file_lookup(int fd)
Looks up a reference to a File corresponding to a given file descriptor.
virtual int close(File *file)=0
Close a file or device.
static File files[]
File descriptor pool.
const char * name
device name
virtual int open(File *file, const char *path, int flags, int mode)=0
Open a file or device.
static int fd_alloc(void)
Allocate a free file descriptor.
static OSMutex mutex
mutual exclusion for fileio
Base class for all File systems.
static int open(struct _reent *reent, const char *path, int flags, int mode)
Open a file or device.
FileSystem * next
next device in linked list
virtual int fstat(File *file, struct stat *stat) override
Get the status information of a file or device.
static DIR * opendir(const char *name)
Open a directory.
static struct dirent * readdir(DIR *dirp)
Read the next entry in a directory.
FileSystem * prev
previous device in linked list
static int fsync(int fd)
Synchronize (flush) a file to disk.
virtual ~FileSystem()
Destructor.
static int close(struct _reent *reent, int fd)
Close a file or device.
static FileSystem * fs_lookup(const char *path)
Locate the file system for a given path.
static int closedir(DIR *dirp)
Close a directory.
static FileSystem * first
first device in linked list
static int stat(struct _reent *reent, const char *path, struct stat *stat)
Get the status information of a file or device.
static int unlink(struct _reent *reent, const char *path)
Remove a file.
void unlock()
Unlock a mutex.
uintptr_t DIR
DIR typedef.
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
uint8_t dir
true if this is a directory, else false
uint8_t device
true if this is a device, false if file system
FileIO * dev
file operations
Directory entry structure.