Proper setPosition implementation


#1

Hi Jules,

Sorry but I'm gonna bother you with this again.

It would be great if Juce had a proper File setPosition implementation.

Currently it always returns true and trim the position to the totoal file length.

It would be great if you called directly platform implementation instead of a lazy seek in read.

IMHO this lazy code should be chosen by the user and not by the implementation.

If you're doing intensive I/O on OSX, you will see a lots of stat calls in the perf analyzer because of uneeded getTotalLength calls.

Plus, you will not see any out of bound seek which could be more error prone IMHO.

Thanks !

 


#2

Yes, it's a good request - would have to be a mode on the FileOutputStream that could be enabled so that existing code won't be affected.


#3

bump :)


#4

Oh, you're talking about the FileInputStream, I thought you meant the output stream. Ok, well actually looking at it, I think the implementation's wrong anyway, because it should fail and return false if it fails to seek to the position that was requested, whereas at the moment it seems to be clamping the position and always returning true. Looks like old code, I'll take a look at it and sanity-check it..


#5

Yep, indeed, I should have been more explicit. Sorry about that.

You have just made my day :)

 

Thanks !