SFML community forums

Help => General => Topic started by: Leinnan on November 16, 2016, 08:25:45 pm

Title: Relative and absolute path
Post by: Leinnan on November 16, 2016, 08:25:45 pm
How to get in SFML absolute path to file based on relative one?
C++11 and SFML 2.4.1
Title: Relative and absolute path
Post by: eXpl0it3r on November 16, 2016, 08:41:16 pm
SFML isn't a filesystem library, thus we don't provide such a functionality.
Unless you meant something else, your description was a bit vague.
Title: Re: Relative and absolute path
Post by: Leinnan on November 16, 2016, 10:16:51 pm
When we open texture file we can just give relative path. I want to do this same, but for std::ifstream.
Title: Re: Relative and absolute path
Post by: Stauricus on November 17, 2016, 01:46:24 am
this doesn''t seem to be a SFML related question, but you don't need to provide the full path just to open an external file with fstream. you can just use
std::ifstream file ("test.txt");
to open a file that is in the same folder your projects is, just make sure the file does exist.
Title: Re: Relative and absolute path
Post by: Hiura on November 17, 2016, 09:56:41 am
Let me just make what Stauricus said a bit more accurate:
[...] you can just use
std::ifstream file ("test.txt");
to open a file that is in the working directory [...]
Title: Re: Relative and absolute path
Post by: Leinnan on November 17, 2016, 08:12:12 pm
Works  ;D
It's strange, when I tried yesterday it didn't work. Maybe i put more chars in path wich I didn't notice.