Files
ESP8266lib/data/formats/DataSourceFile.h
kazu 331f9f3e6c added code for mp3 and jpeg parsing
added interface for data sources
2021-02-28 20:46:38 +01:00

43 lines
692 B
C++

#pragma once
#include "../../ext/sd/File.h"
/** data source using our filesystem */
class DataSourceFile {
File* f;
public:
/** empty ctor */
DataSourceFile() : f(nullptr) {
}
/** ctor with the filesystem file to wrap */
DataSourceFile(File& f) : f(&f) {
}
/** get the current position */
uint32_t curPos() const {
return f->curPos();
}
/** seek to the given position */
void seekTo(uint32_t newPos) {
f->seekTo(newPos);
}
/** read x bytes from the input into dst */
uint32_t read(uint32_t size, uint8_t* dst) {
return f->read(size, dst);
}
/** read an entity */
template <typename T> void readType(T& dst) {
read(sizeof(T), (uint8_t*)&dst);
}
};