/** * File position modes for use with fseek(). */ #define SEEK_SET 0 /* Seek from start */ #define SEEK_CUR 1 /* Seek from current position */ #define SEEK_END 2 /* Seek from end position */
/** * Sets the file position indicator. * * @param file Handle to the file * @param position Position relative to what is specified in whence * @param start SEEK_ constant value of where to see from * * @return 0 on success, a non-zero value otherwise */ native fseek(file, position, start);
I don't see how this would be any simpler than reading the file normally and then loading the menu backwards. With fseek() you can seek to the end of the file, but how are you going to then read line by line backwards?
The only other simple alternative I can think of is using read_file(), specifying line# backwards, but you would first need to determine the number of lines.
Either way, both alternatives are not as simple as what the OP chose.