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

Author Topic: Previous folder in relative path  (Read 918 times)

0 Members and 1 Guest are viewing this topic.

cptkidd62

  • Newbie
  • *
  • Posts: 2
    • View Profile
Previous folder in relative path
« on: August 28, 2022, 10:49:41 pm »
Hi, I'm developing a project using SFML and I have such a folder structure that in the main folder I have /source for code files and /resources for resources. Now, I wanted to load a font to the text using "../resources/fonts/RubikDirt-Regular.ttf" but it does not work. It seems like going up the tree is the problem since the absolute path works fine and I've also used relative paths without dots many times before.
Is there any way to go up the hierarchy in the relative path that works with SFML or do I have to redesign the hierarchy?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Previous folder in relative path
« Reply #1 on: August 29, 2022, 09:04:07 am »
Relative resource paths are relative to the working directory when running the application and not relative to the source code.

In VS the default working directory is for example the project file location.
If you launch an application from say explorer then the working directory is where the executable is located.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cptkidd62

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Previous folder in relative path
« Reply #2 on: August 29, 2022, 02:14:19 pm »
It actually makes sense, I didn't realize that. Now it works, thank you