|
linux, allegro, and directories |
superstar4410
Member #926
January 2001
|
Ok, it would appear that linux has a problem with finding files based on a path. ok heres the part of code that matters spell = load_datafile("spell.dat"); if(!spell) { file_select("load spell.dat", filename, "dat"); spell = load_datafile(filename); if(!spell){no_dat=0;}else{no_dat=1;} } } And when the program runs, the spell.dat is in the same folder as the exe and it dosen't find it and I enter the if(!spell) statement, loading spell from the file_select at runtime it is able load spell.dat So whats the prob?? Don't take yourself too seriously, but do take your responsibilities very seriously. |
Thomas Fjellstrom
Member #476
June 2000
|
are you in the directory that the program is in when you run it? Are you running it from a console? Or just clicking on the program? -- |
spellcaster
Member #1,493
September 2001
|
Check the path parameter. That's not a path you pass here. Try "./" instead. -- |
superstar4410
Member #926
January 2001
|
yea i'm in the directory and I'm clicking on it Don't take yourself too seriously, but do take your responsibilities very seriously. |
Evert
Member #794
November 2000
|
Quote: yea i'm in the directory and I'm clicking on it Right, so your filemanager is in that directory. Try running the program from the command-line (many things work naturally from a terminal in Linux, so it's probably good to get used to those too). Amd make absolutely sure the case of the filename is the same in either case - Linux is case sensitive. |
superstar4410
Member #926
January 2001
|
Ok I found the direct problem, I did some debugging and I found out that at the beginning of ever " " so how can I fix this Thanks [EDIT]:o:o:o:o:o:o Yea you were right, it works from the konsole fine, but from the folder it tries to add /home/superstar4410 before the path Don't take yourself too seriously, but do take your responsibilities very seriously. |
spellcaster
Member #1,493
September 2001
|
use allgros functions to get the path of the executable. -- |
superstar4410
Member #926
January 2001
|
not to be lazy but, could you give me a code example Don't take yourself too seriously, but do take your responsibilities very seriously. |
Evert
Member #794
November 2000
|
The file manager (apparently) starts the program with the working directory set to your home directory. You should probably make the program so that it doesn't care from what directory it is started, as spellcaster suggested. You could probably do (untested!) chdir(get_filename_path(argv[0])); from main, though that isn't exactly nice. |
superstar4410
Member #926
January 2001
|
whats the acutally function name Don't take yourself too seriously, but do take your responsibilities very seriously. |
Steve Terry
Member #1,989
March 2002
|
I think the function you really need is getcwd(); which returns the current working directory.. argv[0] is the application name and does not always contain the path. Oooh it's not ANSI/POSIX compliant... but I know it works in Windows/DOS/Linux... what do they exactly mean by that anyway. ___________________________________ |
Evert
Member #794
November 2000
|
Have a look at the Allegro docs, there's a function like that somewhere that does effectively that. Come to think of it, you shouldn't pass it argv[0], but the result of get_executable_name(). As Steve Terry said though, the result is unreliable. You should really make your game so that it will work from any directory. The config file solution I mentioned above is probably your best bet for now, otherwise just stick with running from a terminal (shouldn't be too hard - you're using make anyway, right ) |
|