29 lines
795 B
C++
29 lines
795 B
C++
#pragma once
|
||
// Storage.h —— TF 卡挂载与互斥
|
||
//
|
||
// TF 卡同一时刻只能被一个"持有者"访问:UI 线程读图、Web 线程传文件。
|
||
// 这里用递归互斥锁把并发访问串起来,锁粒度由调用方决定(整文件操作请持有到结束)。
|
||
#include <Arduino.h>
|
||
#include <vector>
|
||
|
||
namespace hal {
|
||
|
||
bool storageBegin(); // 挂载失败不阻塞启动,只记日志
|
||
bool storageReady();
|
||
uint64_t storageTotalBytes();
|
||
uint64_t storageUsedBytes();
|
||
|
||
void storageLock();
|
||
void storageUnlock();
|
||
|
||
// 目录列举(名字不含路径),失败返回空
|
||
std::vector<String> listDir(const String& dirPath);
|
||
|
||
// 带锁的 RAII 守卫
|
||
struct StorageLock {
|
||
StorageLock() { storageLock(); }
|
||
~StorageLock() { storageUnlock(); }
|
||
};
|
||
|
||
} // namespace hal
|