tinygo-org/tinyfs

Needs implementation of `Seek()` added to tinyfs.File

deadprogram opened this issue · 4 comments

I need to add the io.Seeker interface to tinyfs.File so I can read some data directly from littlefs storage instead of copying into memory first for some code that has to backtrack in the processing of the file.

I noticed that the littlefs implementation does support Seek() but since the fatfs implementation does not, it is not part of that interface.

So, seems like the options are to either try to add to the current fatfs implementation, or to try swapping to @soypat pure go fatfs?

I really need this quickly so any feedback and/or help I can get will be appreciated! 😸

soypat commented

Hey @deadprogram ! The pure go implementation does not have seek implemented yet, maybe I could try adding it sometime this week. Keep in mind the pure go implementation could really use some use and load testing to make sure it does what it says it does. DO NOT USE THE PURE GO FOR REALLY IMPORTANT DATA STORAGE YET!

Here's fatfs's seek: https://github.com/abbrev/fatfs/blob/b11f08931929e5f2f1fe8a3a2c0bd16d222b5625/source/ff.c#L4435-L4589

bgould commented

My opinion would be to add io.Seeker to tinyfs.File and stub out the method to start to always return a "Not Implemented" error or something similar. Probably I could work on an actual implementation and have it ready by the end of this weekend.

bgould commented

For the pure Go implementation I think we could also have another package under this repo ... maybe call it patfs ;)

bgould commented

@deadprogram added the io.Seeker interface and preliminary support for the Seek() method in fatfs (currently only supports seeking from the start of the file) - #20