1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +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:
Earle F. Philhower, III
2019-05-30 10:51:55 -07:00
committed by GitHub
parent 69311c8fe1
commit 44bda41cf6
6 changed files with 74 additions and 5 deletions

View File

@ -283,6 +283,13 @@ bool FS::info(FSInfo& info){
return _impl->info(info);
}
bool FS::info64(FSInfo64& info){
if (!_impl) {
return false;
}
return _impl->info64(info);
}
File FS::open(const String& path, const char* mode) {
return open(path.c_str(), mode);
}

View File

@ -137,6 +137,7 @@ protected:
FS *_baseFS;
};
// Backwards compatible, <4GB filesystem usage
struct FSInfo {
size_t totalBytes;
size_t usedBytes;
@ -146,6 +147,17 @@ struct FSInfo {
size_t maxPathLength;
};
// Support > 4GB filesystems (SD, etc.)
struct FSInfo64 {
uint64_t totalBytes;
uint64_t usedBytes;
size_t blockSize;
size_t pageSize;
size_t maxOpenFiles;
size_t maxPathLength;
};
class FSConfig
{
public:
@ -186,6 +198,7 @@ public:
bool format();
bool info(FSInfo& info);
bool info64(FSInfo64& info);
File open(const char* path, const char* mode);
File open(const String& path, const char* mode);

View File

@ -22,6 +22,7 @@
#include <stddef.h>
#include <stdint.h>
#include <FS.h>
namespace fs {
@ -75,6 +76,7 @@ public:
virtual void end() = 0;
virtual bool format() = 0;
virtual bool info(FSInfo& info) = 0;
virtual bool info64(FSInfo64& info) = 0;
virtual FileImplPtr open(const char* path, OpenMode openMode, AccessMode accessMode) = 0;
virtual bool exists(const char* path) = 0;
virtual DirImplPtr openDir(const char* path) = 0;

View File

@ -85,7 +85,6 @@ public:
bool info(FSInfo& info) override
{
info.maxOpenFiles = _maxOpenFds;
info.blockSize = _blockSize;
info.pageSize = _pageSize;
info.maxOpenFiles = _maxOpenFds;
@ -101,6 +100,20 @@ public:
return true;
}
virtual bool info64(FSInfo64& info64) {
FSInfo i;
if (!info(i)) {
return false;
}
info64.blockSize = i.blockSize;
info64.pageSize = i.pageSize;
info64.maxOpenFiles = i.maxOpenFiles;
info64.maxPathLength = i.maxPathLength;
info64.totalBytes = i.totalBytes;
info64.usedBytes = i.usedBytes;
return true;
}
bool remove(const char* path) override
{
if (!isSpiffsFilenameValid(path)) {