|
|
|
@ -1,8 +1,8 @@ |
|
|
|
|
#include "tag_processor.hpp" |
|
|
|
|
|
|
|
|
|
#include <esp_log.h> |
|
|
|
|
#include <ff.h> |
|
|
|
|
#include <tags.h> |
|
|
|
|
#include <esp_log.h> |
|
|
|
|
|
|
|
|
|
namespace database { |
|
|
|
|
|
|
|
|
@ -16,8 +16,8 @@ struct Aux { |
|
|
|
|
std::string title; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static int read(Tagctx *ctx, void *buf, int cnt) { |
|
|
|
|
Aux *aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
static int read(Tagctx* ctx, void* buf, int cnt) { |
|
|
|
|
Aux* aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
UINT bytes_read; |
|
|
|
|
if (f_read(&aux->file, buf, cnt, &bytes_read) != FR_OK) { |
|
|
|
|
return -1; |
|
|
|
@ -25,8 +25,8 @@ static int read(Tagctx *ctx, void *buf, int cnt) { |
|
|
|
|
return bytes_read; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int seek(Tagctx *ctx, int offset, int whence) { |
|
|
|
|
Aux *aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
static int seek(Tagctx* ctx, int offset, int whence) { |
|
|
|
|
Aux* aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
FRESULT res; |
|
|
|
|
if (whence == 0) { |
|
|
|
|
// Seek from the start of the file. This is f_lseek's behaviour.
|
|
|
|
@ -43,9 +43,14 @@ static int seek(Tagctx *ctx, int offset, int whence) { |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagread f) { |
|
|
|
|
Aux *aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
static void tag(Tagctx* ctx, |
|
|
|
|
int t, |
|
|
|
|
const char* k, |
|
|
|
|
const char* v, |
|
|
|
|
int offset, |
|
|
|
|
int size, |
|
|
|
|
Tagread f) { |
|
|
|
|
Aux* aux = reinterpret_cast<Aux*>(ctx->aux); |
|
|
|
|
if (t == Ttitle) { |
|
|
|
|
aux->title = v; |
|
|
|
|
} else if (t == Tartist) { |
|
|
|
@ -55,8 +60,7 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
toc(Tagctx *ctx, int ms, int offset) {} |
|
|
|
|
static void toc(Tagctx* ctx, int ms, int offset) {} |
|
|
|
|
|
|
|
|
|
} // namespace libtags
|
|
|
|
|
|
|
|
|
@ -65,7 +69,8 @@ static const char* kTag = "TAGS"; |
|
|
|
|
|
|
|
|
|
auto GetInfo(const std::string& path, FileInfo* out) -> bool { |
|
|
|
|
libtags::Aux aux; |
|
|
|
|
if (f_stat(path.c_str(), &aux.info) != FR_OK || f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { |
|
|
|
|
if (f_stat(path.c_str(), &aux.info) != FR_OK || |
|
|
|
|
f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { |
|
|
|
|
ESP_LOGI(kTag, "failed to open file"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|