vote up 1 vote down
star

Hi,

I'm not entirely sure if anyone will know this because it's a pretty old game (yes, I know), but anyway, I have a question about coding for Half-Life 1. Basically, if I make a dll that modifies the game, and then use something like:

ifstream file_in("readme.txt");

I can read from readme.txt, provided it is in the Half-Life directory. But say I put readme.txt in a sub-directory called "game". Now, if I try the following, it won't work:

ifstream file_in("/game/readme.txt");

Anyone know how to code it so that I can read from readme.txt when it's in a subdirectory? Thanks.

flag

1 Answer

vote up 1 vote down
check

To start from the current directory you want to use "./" Prefixing your path with "./" means to start at the working directory.

If the relative path "readme.txt" points to say, "C:/Program Files/Half-Life/readme.txt" then "./game/readme.txt" should point to the absolute path "C:/Program Files/Half-Life/game/readme.txt".

link|flag
Worked a treat. Thanks! – Benji Oct 25 at 5:40

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.