Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Filesystem/AP_Filesystem_ESP32.h
9559 views
1
#pragma once
2
3
#include <stdio.h>
4
#include <string.h>
5
#include <errno.h>
6
#include <sys/unistd.h>
7
#include <sys/types.h>
8
#include <sys/stat.h>
9
#include <fcntl.h>
10
#include <dirent.h>
11
#include "esp_err.h"
12
#include "esp_log.h"
13
#include "esp_vfs_fat.h"
14
#include "driver/sdmmc_host.h"
15
#include "driver/sdspi_host.h"
16
#include "sdmmc_cmd.h"
17
18
#include "AP_Filesystem_backend.h"
19
20
class AP_Filesystem_ESP32 : public AP_Filesystem_Backend
21
{
22
public:
23
// functions that closely match the equivalent posix calls
24
int open(const char *fname, int flags, bool allow_absolute_paths = false) override;
25
int close(int fd) override;
26
int32_t read(int fd, void *buf, uint32_t count) override;
27
int32_t write(int fd, const void *buf, uint32_t count) override;
28
int fsync(int fd) override;
29
int32_t lseek(int fd, int32_t offset, int whence) override;
30
int stat(const char *pathname, struct stat *stbuf) override;
31
int unlink(const char *pathname) override;
32
int mkdir(const char *pathname) override;
33
void *opendir(const char *pathname) override;
34
struct dirent *readdir(void *dirp) override;
35
int closedir(void *dirp) override;
36
int rename(const char *oldpath, const char *newpath) override;
37
38
uint32_t bytes_until_fsync(int fd) override;
39
40
// return free disk space in bytes, -1 on error
41
int64_t disk_free(const char *path) override;
42
43
// return total disk space in bytes, -1 on error
44
int64_t disk_space(const char *path) override;
45
46
// set modification time on a file
47
bool set_mtime(const char *filename, const uint32_t mtime_sec) override;
48
};
49
50
51