Shop OBEX P1 Docs P2 Docs Learn Events
FSRW pread question — Parallax Forums

FSRW pread question

Don MDon M Posts: 1,652
edited 2012-10-17 08:05 in Propeller 1
Using FSRW when I invoke the pread function of reading x number of bytes I know that each time I call that routine it reads the next x number bytes each time. My question is can you go backwards reading the data? If so how is that done?

Comments

  • SRLMSRLM Posts: 5,045
    edited 2012-10-16 19:55
    It doesn't look like FSRW has seek fully implemented. What you could do instead is "seek" inside the buffer that you have read into the Propeller. Usually when I want to go back it's only for a few bytes. If that's the case, then you could simply use the pread buffer pointer that you pass and subtract whatever you want to go back. Of course, you'd need to add support for the edge conditions (ie, back 3 bytes at the start of the buffer).

    Can you post your code?
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-16 20:44
    FSRW 2.6 can do a random seek if the file is open for read. The comment about seek not working in the code is a leftover from the earlier version of FSRW.
  • Don MDon M Posts: 1,652
    edited 2012-10-17 07:45
    Yes I'm using FSRW 2.6.

    So do I understand this correctly- you invoke seek(pos) where pos is the byte position in the sd card file then from that point on it will be the new starting point for a block read?
  • Dave HeinDave Hein Posts: 6,347
    edited 2012-10-17 07:58
    Yes, that's correct.
  • Don MDon M Posts: 1,652
    edited 2012-10-17 08:05
    Thanks. Understood now. Tested and it works.
Sign In or Register to comment.