1

Title might be misleading, however I felt unable to write an accurate one. My apologies.

I'm working on a "partial" FAT32-driver for AVRs, written in C. I'm trying to write a function that would basically read 4 valid entries (skip LFNs and empty entries) from a directory into a buffer. The function keeps track of the current cluster, and the current offset (increments in 32, as entries are 32 bytes) within the cluster.

Now my problem is, I need the function to be able to read four entries forwards (as in, next 4 entries from the current offset), or four entries backwards (before the current offset). My problem right now is the edge-case when reading backwards, you might have some entries on the current cluster, and some entries on the previous one. Should I keep track of all the cluster numbers already read in an array for traversing backwards? I'm just looking for some pointers on what would be an elegant solution.

Thanks in advance!

carazh
  • 11
  • 1
  • 2

1 Answers1

0

It depends of your available RAM, but when you don't need to get the result very fast, then I would recommend not to cache the contents.

Btw. Why you are trying to reinvent the wheel? You could just use something like elm's fat file system.

jeb
  • 78,592
  • 17
  • 171
  • 225