Skip to main content
GameDev.net gamedev.net
🔒 Locked

Relative pathname?

Started by GBGames Oct 13, 2006 at 7:35 AM 1 replies 1.5k views
Original Post
GBGames
GBGames
I just found that if I try to run the binary of my game from a different directory, it can't find the files it is trying to load. Now, my code is trying to open files as "../resources/fileName". So, I figure I must be wrong in my code or my setup, but I am not sure how to handle this problem. How do most games handle this issue? I tried to change it to use "resources/fileName" and copying the binary up one directory, but just as I suspected, it treats it as relative to my current working directory. How do I get my game to work with files relative to itself rather than the user? This may seem like a simple problem, but other than creating a shell script that has "cd gameDirectory; runGameApp", I'm not sure what else to do, and the shell script seems kind of hacky. I also think this could be a general issue and not strictly related to *nix, but for right now I am just trying to get it to work on my Debian system.
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
GBGames
GBGames
Nevermind. I had posted this yesterday at the LGDC mailing list, but since no one responded, I posted here. Shortly afterwards, I thought to look at the games I currently have installed.

They all seem to use a version of Sam Lantinga's FindPath() script. More info can be found here: SDL mailing list post

-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Sander
Sander
I use absolute paths and GNU autoconf to determine the correct paths at build/install time.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.