mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
Add FS::info64 call for filesystems > 4GB (#6154)
Fixes #6082 Add an info64() call which returns used and total sizes as 64 bit quantities. A default wrapper that just copies the 32-bit values is included for LittleFS/SPIFFS which can't hit those capacities.
This commit is contained in:
committed by
GitHub
parent
69311c8fe1
commit
44bda41cf6
@ -94,7 +94,7 @@ public:
|
||||
|
||||
FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) override;
|
||||
|
||||
bool exists(const char* path) {
|
||||
bool exists(const char* path) override {
|
||||
return _mounted ? _fs.exists(path) : false;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ public:
|
||||
return _mounted ? _fs.rename(pathFrom, pathTo) : false;
|
||||
}
|
||||
|
||||
bool info(FSInfo& info) override {
|
||||
bool info64(FSInfo64& info) override {
|
||||
if (!_mounted) {
|
||||
DEBUGV("SDFS::info: FS not mounted\n");
|
||||
return false;
|
||||
@ -113,8 +113,28 @@ public:
|
||||
info.blockSize = _fs.vol()->blocksPerCluster() * 512;
|
||||
info.pageSize = 0; // TODO ?
|
||||
info.maxPathLength = 255; // TODO ?
|
||||
info.totalBytes =_fs.vol()->volumeBlockCount() * 512;
|
||||
info.usedBytes = info.totalBytes - (_fs.vol()->freeClusterCount() * _fs.vol()->blocksPerCluster() * 512);
|
||||
info.totalBytes =_fs.vol()->volumeBlockCount() * 512LL;
|
||||
info.usedBytes = info.totalBytes - (_fs.vol()->freeClusterCount() * _fs.vol()->blocksPerCluster() * 512LL);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool info(FSInfo& info) override {
|
||||
FSInfo64 i;
|
||||
if (!info64(i)) {
|
||||
return false;
|
||||
}
|
||||
info.blockSize = i.blockSize;
|
||||
info.pageSize = i.pageSize;
|
||||
info.maxOpenFiles = i.maxOpenFiles;
|
||||
info.maxPathLength = i.maxPathLength;
|
||||
#ifdef DEBUG_ESP_PORT
|
||||
if (i.totalBytes > (uint64_t)SIZE_MAX) {
|
||||
// This catches both total and used cases, since used must always be < total.
|
||||
DEBUG_ESP_PORT.printf_P(PSTR("WARNING: SD card size overflow (%lld>= 4GB). Please update source to use info64().\n"), i.totalBytes);
|
||||
}
|
||||
#endif
|
||||
info.totalBytes = (size_t)i.totalBytes;
|
||||
info.usedBytes = (size_t)i.usedBytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user