From 4596834b3402c122e563c485e878b70187b2fabf Mon Sep 17 00:00:00 2001 From: Jindra Dolezy Date: Sun, 12 Apr 2015 00:55:10 +0200 Subject: [PATCH] Added espFsFlags function --- espfs/espfs.c | 11 +++++++++++ espfs/espfs.h | 1 + 2 files changed, 12 insertions(+) diff --git a/espfs/espfs.c b/espfs/espfs.c index a08c113..b14a589 100644 --- a/espfs/espfs.c +++ b/espfs/espfs.c @@ -112,6 +112,17 @@ void ICACHE_FLASH_ATTR memcpyAligned(char *dst, char *src, int len) { #define memcpyAligned memcpy #endif +// Returns flags of opened file. +int ICACHE_FLASH_ATTR espFsFlags(EspFsFile *fh) { + if (fh == NULL) { + os_printf("File handle not ready\n"); + return -1; + } + + int8_t flags; + memcpyAligned((char*)&flags, (char*)&fh->header->flags, 1); + return (int)flags; +} //Open a file and return a pointer to the file desc struct. EspFsFile ICACHE_FLASH_ATTR *espFsOpen(char *fileName) { diff --git a/espfs/espfs.h b/espfs/espfs.h index a147fac..c41df0a 100644 --- a/espfs/espfs.h +++ b/espfs/espfs.h @@ -15,6 +15,7 @@ typedef struct EspFsFile EspFsFile; EspFsInitResult espFsInit(void *flashAddress); EspFsFile *espFsOpen(char *fileName); +int espFsFlags(EspFsFile *fh); int espFsRead(EspFsFile *fh, char *buff, int len); void espFsClose(EspFsFile *fh);