OSBasics::tell wrong filesize if file is not opened by physfs

32 views
Skip to first unread message

Sebastian Erhart

unread,
Jun 15, 2014, 5:19:43 PM6/15/14
to polycode-d...@googlegroups.com
Hello,

I just stumbeled over this and thought I might share.

When I open a file with OSBasics::open() and it is not in a physfs managed directory but a plain file, OSBasics will resort to fopen() the file with the passed in arguments.
In this case ftell() will return the length of the file as if you opened the file with mode 'rb' but it will not read it that way making the file size a few bytes off.
This may not sound like much, but the lua interpreter for instance is unable to load a file if you pass the read string and the wrongly calculated file size to luaL_loadbuffer.

This happens on windows 8.1 x64.
Opening the file with mode "rb" fixes this issue.

Regards
Sebastian
Reply all
Reply to author
Forward
0 new messages