1
0
mirror of https://github.com/mist-devel/mist-firmware.git synced 2026-02-06 08:04:49 +00:00
Files
mist-devel.mist-firmware/idxfile.c
2021-06-09 00:55:37 +02:00

37 lines
920 B
C

#include <stdio.h>
#include "idxfile.h"
IDXFile sd_image[SD_IMAGES];
void IDXIndex(IDXFile *pIDXF) {
// builds index to speed up hard file seek
FIL *file = &pIDXF->file;
unsigned long time = GetTimer(0);
FRESULT res;
pIDXF->clmt[0] = SZ_TBL;
file->cltbl = pIDXF->clmt;
DISKLED_ON
res = f_lseek(file, CREATE_LINKMAP);
DISKLED_OFF
if (res != FR_OK) {
iprintf("Error indexing (%d), continuing without indices\n", res);
file->cltbl = 0;
} else {
time = GetTimer(0) - time;
iprintf("File indexed in %lu ms, index size = %d\n", time >> 16, pIDXF->clmt[0]);
}
}
unsigned char IDXOpen(IDXFile *file, const char *name, char mode) {
return f_open(&(file->file), name, mode);
}
void IDXClose(IDXFile *file) {
f_close(&(file->file));
}
unsigned char IDXSeek(IDXFile *file, unsigned long lba) {
return f_lseek(&(file->file), (FSIZE_t) lba << 9);
}