Seeking for a line in file I/O

Technical questions regarding the XTC tools and programming with XMOS.
dsdanielko
Active Member
Posts: 33
Joined: Sat Mar 12, 2016 3:12 pm

Seeking for a line in file I/O

Post by dsdanielko »

https://www.xmos.com/published/how-read ... -execution

I quickly looked over this document and syscall.h but I don't see a way to move the pointer to the start of a specific line on a text file. I am currently using _read to read in a line into a buffer variable. _lseek seems to move the pointer in steps of bytes but my lines of text have varying characters at the ends. Would creating a function to detect newline characters and using it with _lseek work? Since the file is potentially millions of lines long i feel it will be very resource intensive.

Thanks


User avatar
Ross
XCore Expert
Posts: 972
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Can we take a step back a moment? What are you ultimately trying to achieve? (I'm just thinking there might be a better way to do it than reading txt files..)
dsdanielko
Active Member
Posts: 33
Joined: Sat Mar 12, 2016 3:12 pm

Post by dsdanielko »

Matlab creates a text file (200000+ lines long) with a bunch of parameters that are used by the startKIT to control a speaker.
The startKIT goes through the file line by line each loop to get the parameters for the next task.