mirror of https://github.com/ArduPilot/ardupilot
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/*
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "AP_Filesystem_backend.h"
|
|
|
|
class AP_Filesystem_Sys : public AP_Filesystem_Backend
|
|
{
|
|
public:
|
|
// functions that closely match the equivalent posix calls
|
|
int open(const char *fname, int flags) override;
|
|
int close(int fd) override;
|
|
int32_t read(int fd, void *buf, uint32_t count) override;
|
|
int32_t lseek(int fd, int32_t offset, int whence) override;
|
|
int stat(const char *pathname, struct stat *stbuf) override;
|
|
|
|
private:
|
|
// only allow up to 4 files at a time
|
|
static constexpr uint8_t max_open_file = 4;
|
|
|
|
struct file_data {
|
|
char *data;
|
|
size_t length;
|
|
};
|
|
|
|
struct rfile {
|
|
bool open;
|
|
uint32_t file_ofs;
|
|
struct file_data *data;
|
|
} file[max_open_file];
|
|
};
|