1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #pragma once
- #include <stdint.h>
- #include <AP_HAL/AP_HAL_Boards.h>
- #if HAL_OS_POSIX_IO || HAL_OS_FATFS_IO
- #define HAVE_FILESYSTEM_SUPPORT 1
- #else
- #define HAVE_FILESYSTEM_SUPPORT 0
- #endif
- #if HAVE_FILESYSTEM_SUPPORT
- #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
- #include "AP_Filesystem_FATFS.h"
- #endif
- #if CONFIG_HAL_BOARD == HAL_BOARD_LINUX || CONFIG_HAL_BOARD == HAL_BOARD_SITL
- #include "AP_Filesystem_posix.h"
- #endif
- class AP_Filesystem {
- public:
- AP_Filesystem() {}
-
- int open(const char *fname, int flags);
- int close(int fd);
- ssize_t read(int fd, void *buf, size_t count);
- ssize_t write(int fd, const void *buf, size_t count);
- int fsync(int fd);
- off_t lseek(int fd, off_t offset, int whence);
- int stat(const char *pathname, struct stat *stbuf);
- int unlink(const char *pathname);
- int mkdir(const char *pathname);
- DIR *opendir(const char *pathname);
- struct dirent *readdir(DIR *dirp);
- int closedir(DIR *dirp);
-
- int64_t disk_free(const char *path);
-
- int64_t disk_space(const char *path);
-
- bool set_mtime(const char *filename, const time_t mtime_sec);
- };
- namespace AP {
- AP_Filesystem &FS();
- };
- #endif
|