fix #276 rename macro FILE_READ/WRITE to enum FILE_O_READ/WRITE

to avoid conflict with other filesystem define
This commit is contained in:
hathach committed 2019-05-30 18:09:07 +07:00
1 parent 9b37e28bc2
commit b99cae32b6
8 files changed
+33 -26

No files matched your search

@@ -46,7 +46,7 @@ class Adafruit_LittleFS
// Open the specified file/directory with the supplied mode (e.g. read or
// write, etc). Returns a File object for interacting with the file.
// Note that currently only one file can be open at a time.
Adafruit_LittleFS_Namespace::File open (char const *filename, uint8_t mode = FILE_READ);
Adafruit_LittleFS_Namespace::File open (char const *filename, uint8_t mode = Adafruit_LittleFS_Namespace::FILE_O_READ);
// Methods to determine if the requested file path exists.
bool exists (char const *filepath);
@@ -51,8 +51,8 @@ File::File (char const *filename, uint8_t mode, Adafruit_LittleFS &fs)
bool File::_open_file (char const *filepath, uint8_t mode)
{
int flags = (mode == FILE_READ) ? LFS_O_RDONLY :
(mode == FILE_WRITE) ? (LFS_O_RDWR | LFS_O_CREAT) : 0;
int flags = (mode == FILE_O_READ) ? LFS_O_RDONLY :
(mode == FILE_O_WRITE) ? (LFS_O_RDWR | LFS_O_CREAT) : 0;
if ( flags )
{
@@ -69,7 +69,7 @@ bool File::_open_file (char const *filepath, uint8_t mode)
}
// move to end of file
if ( mode == FILE_WRITE ) lfs_file_seek(_fs->getFS(), _file, 0, LFS_SEEK_END);
if ( mode == FILE_O_WRITE ) lfs_file_seek(_fs->getFS(), _file, 0, LFS_SEEK_END);
_is_dir = false;
}
@@ -116,8 +116,8 @@ bool File::open (char const *filepath, uint8_t mode)
}
else if ( LFS_ERR_NOENT == rc )
{
// file not existed, only proceed with FILE_WRITE mode
if ( mode == FILE_WRITE ) ret = _open_file(filepath, mode);
// file not existed, only proceed with FILE_O_WRITE mode
if ( mode == FILE_O_WRITE ) ret = _open_file(filepath, mode);
}
else
{
@@ -25,15 +25,19 @@
#ifndef ADAFRUIT_LITTLEFS_FILE_H_
#define ADAFRUIT_LITTLEFS_FILE_H_
#define FILE_READ 0
#define FILE_WRITE 1
// Forward declaration
class Adafruit_LittleFS;
namespace Adafruit_LittleFS_Namespace
{
// avoid conflict with other FileSystem FILE_READ/FILE_WRITE
enum
{
FILE_O_READ = 0,
FILE_O_WRITE = 1,
};
class File : public Stream
{
public:
@@ -69,7 +73,7 @@ class File : public Stream
char const* name (void);
bool isDirectory (void);
File openNextFile (uint8_t mode = FILE_READ);
File openNextFile (uint8_t mode = FILE_O_READ);
void rewindDirectory (void);
private: