Fix psd load error on windows#425
Conversation
On windows, ifstream::open does not garantee to be at the beginning of the file.
|
Really? What are the circumstances in which something else happens? |
|
LGTM, by the way, I'm just curious about what's really going on here. Also, do you need this backported to any release branches, or only the master? |
No idea ! Just systematically reads values from anywhere when I load a psd on windows...
Only master. |
|
Yikes, this one makes me uncomfortable. The behaviour that std::ifstream file("blah") reads from the beginning seems like very basic and important standard behaviour. Reading section 27.9.1.4 of the C++ standard http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3376.pdf says that the underlying filebuf is opened as if by calling fopen() with mode "rb". I too wonder what's really going on here... |
|
I'm uncomfortable with the weirdness of this, I'm worried we're just masking another problem. Do you have a specific PSD file that can reproduce the problem? (Can you send it to me? Or does it have this problem for all PSD files?) I think you should try this: instead of seeking, try instead checking and printing the current file position : Let us know what it prints. And if it never prints anything at all, then perhaps this is not the problem. |
|
It's not specific to one psd file. See the streampos before and after the manual seekg to 0. |
|
Does that answer your question? |
|
Sorry, the image appears to have no size for me. Can you just cut and paste the text? |
|
Can't use your code directly as std::streampos is an implementation defined class. ////////////////////////////////////////////////////// Debug values: pos1._Stz == 0 pos2._Stz == 0 |
|
This patch is no longer necessary, since we have added the seek() to Filesystem::open, it happens automatically on Windows. Closing. |
On windows, ifstream::open does not guarantee to be at the beginning of
the file.