Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Relative and absolute path  (Read 6862 times)

0 Members and 1 Guest are viewing this topic.

Leinnan

  • Newbie
  • *
  • Posts: 10
    • View Profile
Relative and absolute path
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Relative and absolute path
« Reply #1 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.
« Last Edit: November 16, 2016, 08:43:14 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Leinnan

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Relative and absolute path
« Reply #2 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.

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Relative and absolute path
« Reply #3 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.
Visit my game site (and hopefully help funding it? )
Website | IndieDB

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Relative and absolute path
« Reply #4 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 [...]
SFML / OS X developer

Leinnan

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Relative and absolute path
« Reply #5 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.

 

anything