You can get the file length with file.getLength() so if you just care about the number of records I'd say guess the length of a line and then just divide the length by that?
It would be possible to add a seek function, However I feel like read at location isn't hugely useful because as you can't store binary data, generally each record is a variable length - so it's not like you can just seek to the end record... You'd have to seek to maybe 100 bytes before the end and then just read lines until you got to the last one.
I guess what data are you actually trying to find? Is it just that you want to get the final record out of the file, or is it something else?
I'd actually intended to redo the StorageFile handling such that it could store binary data - and in that case I feel like it would actually be really handy.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
You can get the file length with
file.getLength()
so if you just care about the number of records I'd say guess the length of a line and then just divide the length by that?StorageFile reference here: http://www.espruino.com/Reference#StorageFile
It would be possible to add a
seek
function, However I feel like read at location isn't hugely useful because as you can't store binary data, generally each record is a variable length - so it's not like you can just seek to the end record... You'd have to seek to maybe 100 bytes before the end and then just read lines until you got to the last one.I guess what data are you actually trying to find? Is it just that you want to get the final record out of the file, or is it something else?
I'd actually intended to redo the StorageFile handling such that it could store binary data - and in that case I feel like it would actually be really handy.