mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-07 00:04:36 +03:00
Replacing boolean parameters to SD.open() with SD_MODE constants.
This commit is contained in:
@@ -343,7 +343,7 @@ boolean SDClass::begin(uint8_t csPin) {
|
||||
}
|
||||
|
||||
|
||||
File SDClass::open(char *filepath, boolean write, boolean append) {
|
||||
File SDClass::open(char *filepath, uint8_t mode) {
|
||||
/*
|
||||
|
||||
Open the supplied file path for reading or writing.
|
||||
@@ -369,18 +369,7 @@ File SDClass::open(char *filepath, boolean write, boolean append) {
|
||||
|
||||
// TODO: Allow for read&write? (Possibly not, as it requires seek.)
|
||||
|
||||
uint8_t oflag = O_RDONLY;
|
||||
|
||||
if (write) {
|
||||
oflag = O_CREAT | O_WRITE;
|
||||
if (append) {
|
||||
oflag |= O_APPEND;
|
||||
} else {
|
||||
oflag |= O_TRUNC;
|
||||
}
|
||||
}
|
||||
|
||||
fileOpenMode = oflag;
|
||||
fileOpenMode = mode;
|
||||
walkPath(filepath, root, callback_openPath, this);
|
||||
|
||||
return File();
|
||||
|
@@ -20,6 +20,10 @@
|
||||
#include <utility/SdFat.h>
|
||||
#include <utility/SdFatUtil.h>
|
||||
|
||||
#define SD_READ O_READ
|
||||
#define SD_TRUNCATE (O_WRITE | O_CREAT | O_TRUNC)
|
||||
#define SD_APPEND (O_WRITE | O_CREAT | O_APPEND)
|
||||
|
||||
class File : public Stream {
|
||||
public:
|
||||
virtual void write(uint8_t);
|
||||
@@ -49,7 +53,7 @@ public:
|
||||
// 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.
|
||||
File open(char *filename, boolean write = false, boolean append = true);
|
||||
File open(char *filename, uint8_t mode = SD_READ);
|
||||
|
||||
// Methods to determine if the requested file path exists.
|
||||
boolean exists(char *filepath);
|
||||
|
Reference in New Issue
Block a user