open, read, write seems to work
This commit is contained in:
1 parent
e38c37b6b7
commit
86d63af7c8
4 files changed
+13
-10
No files matched your search
@@ -12,7 +12,9 @@
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <Bluefruit_FileIO.h>
|
||||
#include <Adafruit_LittleFS.h>
|
||||
|
||||
using namespace LittleFilesystem;
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup()
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
*********************************************************************/
|
||||
|
||||
#include <bluefruit.h>
|
||||
#include <Bluefruit_FileIO.h>
|
||||
#include <Adafruit_LittleFS.h>
|
||||
|
||||
using namespace LittleFilesystem;
|
||||
|
||||
/* This example print out Internal Flash contents up to
|
||||
* MAX_LEVEL level of directories (including root)
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
any redistribution
|
||||
*********************************************************************/
|
||||
|
||||
#include <Bluefruit_FileIO.h>
|
||||
#include <Adafruit_LittleFS.h>
|
||||
using namespace LittleFilesystem;
|
||||
|
||||
#define FILENAME "/adafruit.txt"
|
||||
|
||||
#define CONTENTS "Bluefruit Feather52's file contents"
|
||||
#define FILENAME "/adafruit2.txt"
|
||||
#define CONTENTS "Adafruit Little File System test file contents"
|
||||
|
||||
File file(InternalFS);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ File::File (char const *filename, uint8_t mode, Adafruit_LittleFS &fs)
|
||||
_path = NULL;
|
||||
_is_dir = false;
|
||||
|
||||
open(filename, mode);
|
||||
this->open(filename, mode);
|
||||
}
|
||||
|
||||
File& File::operator = (const File &rhs)
|
||||
@@ -130,19 +130,18 @@ bool File::open (char const *filepath, uint8_t mode)
|
||||
// close if currently opened
|
||||
if ( _file ) close();
|
||||
|
||||
File file(*_fs);
|
||||
struct lfs_info info;
|
||||
|
||||
int rc = lfs_stat(_fs->getFS(), filepath, &info);
|
||||
if ( LFS_ERR_OK == rc )
|
||||
{
|
||||
// file existed, open file or directory accordingly
|
||||
file = (info.type == LFS_TYPE_REG) ? _open_file(filepath, mode) : _open_dir(filepath);
|
||||
*this = (info.type == LFS_TYPE_REG) ? _open_file(filepath, mode) : _open_dir(filepath);
|
||||
}
|
||||
else if ( LFS_ERR_NOENT == rc )
|
||||
{
|
||||
// file not existed, only proceed with FILE_WRITE mode
|
||||
if ( mode == FILE_WRITE ) file = _open_file(filepath, mode);
|
||||
if ( mode == FILE_WRITE ) *this = _open_file(filepath, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user