43 lines
692 B
C++
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);
|
|
}
|
|
|
|
};
|