Getting the size of a file and rewinding a file? #315
Replies: 4 comments
-
Posted at 2014-09-22 by @gfwilliams Hi, Right now you'll have to find out the file size by just reading bytes until you reach the end of the file I'm afraid. I've put an issue on GitHub for it though, and will try and add something. To try and stay like node.js, I'll probably just use something like For rewinding, you'll have to reopen the file (as you're doing). I'm not sure re-opening it is that much slower than a |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-26 by Kelvin Pardon my late reply. It sounds like a good news! Would definitely be looking forward to both of these two being implemented, if possible. If we can make it both possible, then probably we'd benefit from getting the current reading position as well (similar in behaviour to |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-26 by @gfwilliams At the moment it's still a battle to keep the size of Espruino's firmware down, so I'm afraid I'll leave At some point I'll switch to size optimisation, which will hurt performance a bit but will give an extra 50kB or so to cram everything into. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-30 by Kelvin Indeed. BTW, just saw that the fs.stat and File.seek are now on the repo. Perhaps should try it out later tonight if I get the chance to. Thanks anyway! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-09-22 by Kelvin
Not sure if this is the right place to ask, but I am recently involved in a pet project (will certainly post more on that when it's ready :)) that would benefit from getting the file size of a particular file as well as "rewinding" a file pipe to the very beginning. For the latter function currently what I am doing right now is to close the file handle and reopening at the same path so to mimic this behavior, but for now I really have no idea how to get the size of a particular file.
Would there be a future API update for these? Or is it that it is in fact possible at this stage that I happened to miss? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions