Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Filesystem/AP_Filesystem_ROMFS.h
Views: 1798
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#pragma once1617#include "AP_Filesystem_config.h"1819#if AP_FILESYSTEM_ROMFS_ENABLED2021#include "AP_Filesystem_backend.h"2223class AP_Filesystem_ROMFS : public AP_Filesystem_Backend24{25public:26// functions that closely match the equivalent posix calls27int open(const char *fname, int flags, bool allow_absolute_paths = false) override;28int close(int fd) override;29int32_t read(int fd, void *buf, uint32_t count) override;30int32_t write(int fd, const void *buf, uint32_t count) override;31int fsync(int fd) override;32int32_t lseek(int fd, int32_t offset, int whence) override;33int stat(const char *pathname, struct stat *stbuf) override;34int unlink(const char *pathname) override;35int mkdir(const char *pathname) override;36void *opendir(const char *pathname) override;37struct dirent *readdir(void *dirp) override;38int closedir(void *dirp) override;3940// return free disk space in bytes, -1 on error41int64_t disk_free(const char *path) override;4243// return total disk space in bytes, -1 on error44int64_t disk_space(const char *path) override;4546// set modification time on a file47bool set_mtime(const char *filename, const uint32_t mtime_sec) override;4849/*50load a full file. Use delete to free the data51*/52FileData *load_file(const char *filename) override;5354// unload data from load_file()55void unload_file(FileData *fd) override;5657private:58// only allow up to 4 files at a time59static constexpr uint8_t max_open_file = 4;60static constexpr uint8_t max_open_dir = 4;61struct rfile {62const uint8_t *data;63uint32_t size;64uint32_t ofs;65} file[max_open_file];6667// allow up to 4 directory opens68struct rdir {69char *path;70uint16_t ofs;71struct dirent de;72} dir[max_open_dir];73};7475#endif // AP_FILESYSTEM_ROMFS_ENABLED767778