瀏覽代碼

Support open with FILE_WRITE_BEGIN mode

main
PaulStoffregen 4 年之前
父節點
當前提交
030244e90f
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. +6
    -4
      src/SD.h

+ 6
- 4
src/SD.h 查看文件

@@ -53,10 +53,11 @@
class SDFile : public File
{
private:
// Classes derived from File are never meant to be constructed from
// anywhere other than openNextFile() and open() in their parent FS
// class. Only the abstract File class which references these
// derived classes is meant to have a public constructor!
// Classes derived from File are never meant to be constructed
// anywhere other than open() in the parent FS class and
// openNextFile() while traversing a directory.
// Only the abstract File class which references these derived
// classes is meant to have a public constructor!
SDFile(const SDFAT_FILE &file) : sdfatfile(file), filename(nullptr) { }
friend class SDClass;
public:
@@ -158,6 +159,7 @@ public:
File open(const char *filepath, uint8_t mode = FILE_READ) {
oflag_t flags = O_READ;
if (mode == FILE_WRITE) flags = O_RDWR | O_CREAT | O_AT_END;
else if (mode == FILE_WRITE_BEGIN) flags = O_RDWR | O_CREAT;
SDFAT_FILE file = sdfs.open(filepath, flags);
if (file) return File(new SDFile(file));
return File();

Loading…
取消
儲存