• Advertisement
Sign in to follow this  

File Reading Bug(?) with Linux and SDL

This topic is 1518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,

 

I switched to Ubuntu yesterday and wanted to continue my project. And everything works fine but one little thing not:

I am reading some img-paths from a text file, sorted like this:

 

img/ground/grass1.png

img/ground/grass2.png

...

 

On Windows everything worked fine. When i now want to start the program with Linux it works, but it cannot open the files with the path that was read from the config-file.

If i use the function manualy like loadTexture("img/ground/grass1.png") it works! ( Function: loadTexture( const char* path ) ).

 

Is there a known bug with File handling in Linux?

 

Thanks,

 

Daniel

 

Share this post


Link to post
Share on other sites
Advertisement

When you read from the config file, does the filename string you're getting have a \r at the end of it? Reading a line from a file in text-mode differs on Linux vs Windows. Windows will look for \r\n to indicate a new line, whereas Linux will look for \n. If your config file was written on Windows, it's likely that the line endings are \r\n. When you read that file in Linux it considers the \r as part of the line, and so you might actually be trying to load "img/ground/grass1.png\r".

Share this post


Link to post
Share on other sites


Is there a known bug with File handling in Linux?

Something that you should learn sooner rather than later is that the probability of a bug in mature and widely used tool is extremely low. Your code is almost certainly at fault, you should assume that it is until you can prove otherwise.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement