mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-16 00:43:00 +03:00
Make SPIFFS and LittleFS stay out of link when not needed (#6699)
* define two weak functions defaulting to no-op redefine them to do something useful when either spiffs or littlefs are used * noop * single entry point for closing FSes * rename functions, override when instanciated, add link to explanation * spiffs: call end on destructor
This commit is contained in:
@ -245,6 +245,13 @@ protected:
|
||||
|
||||
} // namespace fs
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void close_all_fs(void);
|
||||
void littlefs_request_end(void);
|
||||
void spiffs_request_end(void);
|
||||
}
|
||||
|
||||
#ifndef FS_NO_GLOBALS
|
||||
using fs::FS;
|
||||
using fs::File;
|
||||
|
33
cores/esp8266/FSnoop.cpp
Normal file
33
cores/esp8266/FSnoop.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* no-op implementations
|
||||
* used/linked when no strong implementation already exists elsewhere
|
||||
*/
|
||||
|
||||
#include <FS.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void close_all_fs(void)
|
||||
{
|
||||
littlefs_request_end();
|
||||
spiffs_request_end();
|
||||
}
|
||||
|
||||
// default weak definitions
|
||||
// they are overriden in their respective real implementation
|
||||
// hint: https://github.com/esp8266/Arduino/pull/6699#issuecomment-549085382
|
||||
|
||||
void littlefs_request_end(void) __attribute__((weak));
|
||||
void littlefs_request_end(void)
|
||||
{
|
||||
//ets_printf("debug: noop: littlefs_request_end\n");
|
||||
}
|
||||
|
||||
void spiffs_request_end(void) __attribute__((weak));
|
||||
void spiffs_request_end(void)
|
||||
{
|
||||
//ets_printf("debug: noop: spiffs_request_end\n");
|
||||
}
|
||||
|
||||
}
|
@ -141,6 +141,14 @@ FS SPIFFS = FS(FSImplPtr(new spiffs_impl::SPIFFSImpl(
|
||||
FS_PHYS_PAGE,
|
||||
FS_PHYS_BLOCK,
|
||||
SPIFFS_MAX_OPEN_FILES)));
|
||||
|
||||
extern "C" void spiffs_request_end(void)
|
||||
{
|
||||
// override default weak function
|
||||
//ets_printf("debug: not weak spiffs end\n");
|
||||
SPIFFS.end();
|
||||
}
|
||||
|
||||
#endif // ARDUINO
|
||||
#endif // !CORE_MOCK
|
||||
|
||||
|
@ -80,6 +80,11 @@ public:
|
||||
memset(&_fs, 0, sizeof(_fs));
|
||||
}
|
||||
|
||||
~SPIFFSImpl()
|
||||
{
|
||||
end();
|
||||
}
|
||||
|
||||
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
|
||||
bool exists(const char* path) override;
|
||||
DirImplPtr openDir(const char* path) override;
|
||||
|
Reference in New Issue
Block a user