diff --git a/libraries/FileSystem/src/InternalFS.cpp b/libraries/FileSystem/src/InternalFS.cpp index 1073884e..19ff0aff 100644 --- a/libraries/FileSystem/src/InternalFS.cpp +++ b/libraries/FileSystem/src/InternalFS.cpp @@ -182,6 +182,8 @@ LittleFS::LittleFS (void) _lfs_cfg.block_size = LFS_BLOCK_SIZE; _lfs_cfg.block_count = LFS_FLASH_SIZE / LFS_BLOCK_SIZE; _lfs_cfg.lookahead = 128; + + _begun = false; } LittleFS::~LittleFS () @@ -191,6 +193,9 @@ LittleFS::~LittleFS () bool LittleFS::begin (void) { + if ( _begun ) return true; + _begun = true; + int err = lfs_mount(&_lfs, &_lfs_cfg); // reformat if we can't mount the filesystem diff --git a/libraries/FileSystem/src/InternalFS.h b/libraries/FileSystem/src/InternalFS.h index 9ae527c4..778a6d00 100644 --- a/libraries/FileSystem/src/InternalFS.h +++ b/libraries/FileSystem/src/InternalFS.h @@ -68,12 +68,12 @@ class LittleFS: public BluefuritLib::FileSystemClass virtual void _f_rewindDirectory (void* fhdl); private: - BluefuritLib::File _open_file (char const *filepath, uint8_t mode); - BluefuritLib::File _open_dir (char const *filepath); - struct lfs_config _lfs_cfg; lfs_t _lfs; + bool _begun; + BluefuritLib::File _open_file (char const *filepath, uint8_t mode); + BluefuritLib::File _open_dir (char const *filepath); }; extern LittleFS InternalFS;