Jump to content

  • Log In with Google      Sign In   
  • Create Account


File Reading Bug(?) with Linux and SDL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Agreon   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 November 2013 - 03:17 PM

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

 



Sponsor:

#2 Samith   Members   -  Reputation: 1914

Like
4Likes
Like

Posted 23 November 2013 - 03:22 PM

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".



#3 Agreon   Members   -  Reputation: 158

Like
0Likes
Like

Posted 23 November 2013 - 03:26 PM

Thanks, i will try it out!

 

Ok, that was my problem. Thanky you!



#4 rip-off   Moderators   -  Reputation: 7650

Like
4Likes
Like

Posted 24 November 2013 - 06:26 AM


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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS