mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
Update to SdFat 2.1.1 with UTF-8 support (#8355)
This commit is contained in:
committed by
GitHub
parent
7d971fa45b
commit
a00b2d7091
@ -64,13 +64,13 @@ FileImplPtr SDFSImpl::open(const char* path, OpenMode openMode, AccessMode acces
|
||||
}
|
||||
free(pathStr);
|
||||
}
|
||||
sdfat::File32 fd = _fs.open(path, flags);
|
||||
File32 fd = _fs.open(path, flags);
|
||||
if (!fd) {
|
||||
DEBUGV("SDFSImpl::openFile: fd=%p path=`%s` openMode=%d accessMode=%d",
|
||||
&fd, path, openMode, accessMode);
|
||||
return FileImplPtr();
|
||||
}
|
||||
auto sharedFd = std::make_shared<sdfat::File32>(fd);
|
||||
auto sharedFd = std::make_shared<File32>(fd);
|
||||
return std::make_shared<SDFSFileImpl>(this, sharedFd, path);
|
||||
}
|
||||
|
||||
@ -90,14 +90,14 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
}
|
||||
// At this point we have a name of "/blah/blah/blah" or "blah" or ""
|
||||
// If that references a directory, just open it and we're done.
|
||||
sdfat::File32 dirFile;
|
||||
File32 dirFile;
|
||||
const char *filter = "";
|
||||
if (!pathStr[0]) {
|
||||
// openDir("") === openDir("/")
|
||||
dirFile = _fs.open("/", sdfat::O_RDONLY);
|
||||
dirFile = _fs.open("/", O_RDONLY);
|
||||
filter = "";
|
||||
} else if (_fs.exists(pathStr)) {
|
||||
dirFile = _fs.open(pathStr, sdfat::O_RDONLY);
|
||||
dirFile = _fs.open(pathStr, O_RDONLY);
|
||||
if (dirFile.isDir()) {
|
||||
// Easy peasy, path specifies an existing dir!
|
||||
filter = "";
|
||||
@ -107,12 +107,12 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (!ptr) {
|
||||
// No slashes, open the root dir
|
||||
dirFile = _fs.open("/", sdfat::O_RDONLY);
|
||||
dirFile = _fs.open("/", O_RDONLY);
|
||||
filter = pathStr;
|
||||
} else {
|
||||
// We've got slashes, open the dir one up
|
||||
*ptr = 0; // Remove slash, truncare string
|
||||
dirFile = _fs.open(pathStr, sdfat::O_RDONLY);
|
||||
dirFile = _fs.open(pathStr, O_RDONLY);
|
||||
filter = ptr + 1;
|
||||
}
|
||||
}
|
||||
@ -122,12 +122,12 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (!ptr) {
|
||||
// No slashes, open the root dir
|
||||
dirFile = _fs.open("/", sdfat::O_RDONLY);
|
||||
dirFile = _fs.open("/", O_RDONLY);
|
||||
filter = pathStr;
|
||||
} else {
|
||||
// We've got slashes, open the dir one up
|
||||
*ptr = 0; // Remove slash, truncare string
|
||||
dirFile = _fs.open(pathStr, sdfat::O_RDONLY);
|
||||
dirFile = _fs.open(pathStr, O_RDONLY);
|
||||
filter = ptr + 1;
|
||||
}
|
||||
}
|
||||
@ -135,7 +135,7 @@ DirImplPtr SDFSImpl::openDir(const char* path)
|
||||
DEBUGV("SDFSImpl::openDir: path=`%s`\n", path);
|
||||
return DirImplPtr();
|
||||
}
|
||||
auto sharedDir = std::make_shared<sdfat::File32>(dirFile);
|
||||
auto sharedDir = std::make_shared<File32>(dirFile);
|
||||
auto ret = std::make_shared<SDFSDirImpl>(filter, this, sharedDir, pathStr);
|
||||
free(pathStr);
|
||||
return ret;
|
||||
@ -145,12 +145,12 @@ bool SDFSImpl::format() {
|
||||
if (_mounted) {
|
||||
return false;
|
||||
}
|
||||
sdfat::SdCardFactory cardFactory;
|
||||
sdfat::SdCard* card = cardFactory.newCard(sdfat::SdSpiConfig(_cfg._csPin, DEDICATED_SPI, _cfg._spiSettings));
|
||||
SdCardFactory cardFactory;
|
||||
SdCard* card = cardFactory.newCard(SdSpiConfig(_cfg._csPin, DEDICATED_SPI, _cfg._spiSettings));
|
||||
if (!card || card->errorCode()) {
|
||||
return false;
|
||||
}
|
||||
sdfat::FatFormatter fatFormatter;
|
||||
FatFormatter fatFormatter;
|
||||
uint8_t *sectorBuffer = new uint8_t[512];
|
||||
bool ret = fatFormatter.format(card, sectorBuffer, nullptr);
|
||||
delete[] sectorBuffer;
|
||||
|
Reference in New Issue
Block a user