Skip to content

Commit 86d63af

Browse files
committed
open, read, write seems to work
1 parent e38c37b commit 86d63af

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

libraries/Adafruit_LittleFS/examples/Internal_Format/Internal_Format.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
any redistribution
1313
*********************************************************************/
1414

15-
#include <Bluefruit_FileIO.h>
15+
#include <Adafruit_LittleFS.h>
16+
17+
using namespace LittleFilesystem;
1618

1719
// the setup function runs once when you press reset or power the board
1820
void setup()

libraries/Adafruit_LittleFS/examples/Internal_ListFiles/Internal_ListFiles.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
*********************************************************************/
1414

1515
#include <bluefruit.h>
16-
#include <Bluefruit_FileIO.h>
16+
#include <Adafruit_LittleFS.h>
17+
18+
using namespace LittleFilesystem;
1719

1820
/* This example print out Internal Flash contents up to
1921
* MAX_LEVEL level of directories (including root)

libraries/Adafruit_LittleFS/examples/Internal_ReadWrite/Internal_ReadWrite.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
any redistribution
1313
*********************************************************************/
1414

15-
#include <Bluefruit_FileIO.h>
15+
#include <Adafruit_LittleFS.h>
16+
using namespace LittleFilesystem;
1617

17-
#define FILENAME "/adafruit.txt"
18-
19-
#define CONTENTS "Bluefruit Feather52's file contents"
18+
#define FILENAME "/adafruit2.txt"
19+
#define CONTENTS "Adafruit Little File System test file contents"
2020

2121
File file(InternalFS);
2222

libraries/Adafruit_LittleFS/src/Adafruit_LittleFS_File.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ File::File (char const *filename, uint8_t mode, Adafruit_LittleFS &fs)
5050
_path = NULL;
5151
_is_dir = false;
5252

53-
open(filename, mode);
53+
this->open(filename, mode);
5454
}
5555

5656
File& File::operator = (const File &rhs)
@@ -130,19 +130,18 @@ bool File::open (char const *filepath, uint8_t mode)
130130
// close if currently opened
131131
if ( _file ) close();
132132

133-
File file(*_fs);
134133
struct lfs_info info;
135134

136135
int rc = lfs_stat(_fs->getFS(), filepath, &info);
137136
if ( LFS_ERR_OK == rc )
138137
{
139138
// file existed, open file or directory accordingly
140-
file = (info.type == LFS_TYPE_REG) ? _open_file(filepath, mode) : _open_dir(filepath);
139+
*this = (info.type == LFS_TYPE_REG) ? _open_file(filepath, mode) : _open_dir(filepath);
141140
}
142141
else if ( LFS_ERR_NOENT == rc )
143142
{
144143
// file not existed, only proceed with FILE_WRITE mode
145-
if ( mode == FILE_WRITE ) file = _open_file(filepath, mode);
144+
if ( mode == FILE_WRITE ) *this = _open_file(filepath, mode);
146145
}
147146
else
148147
{

0 commit comments

Comments
 (0)