AP_Filesystem: expose APFS_FILE structure

allows scripting to set the fd for sendfile()
This commit is contained in:
Andrew Tridgell 2023-12-08 05:29:01 +11:00
parent 26d814880e
commit c9c38300bd
2 changed files with 8 additions and 9 deletions

View File

@ -30,14 +30,6 @@
#include <stdarg.h>
#include <AP_Math/AP_Math.h>
struct apfs_file {
int fd;
bool error;
bool eof;
int16_t unget;
char *tmpfile_name;
};
#define CHECK_STREAM(stream, ret) while (stream == NULL || stream->fd < 0) { errno = EBADF; return ret; }
#define modecmp(str, pat) (strcmp(str, pat) == 0 ? 1: 0)

View File

@ -20,6 +20,7 @@
#include <sys/types.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@ -29,7 +30,13 @@ extern "C" {
these are here to allow lua to build on HAL_ChibiOS
*/
typedef struct apfs_file APFS_FILE;
typedef struct apfs_file {
int fd;
bool error;
bool eof;
int16_t unget;
char *tmpfile_name;
} APFS_FILE;
APFS_FILE *apfs_fopen(const char *pathname, const char *mode);
int apfs_fprintf(APFS_FILE *stream, const char *format, ...);