bool aeSpriteBase::Init(char * dir)
{
char buffer[255];
char filename[255];
char name[255];
FILE * fp;
sprintf(filename,"%s/info",dir);
if( (fp = fopen(filename,"r")) == NULL )
{
fprintf(stderr,"Error opening file: %s\n",filename);
return false;
}
...
}
File open error
Hi, I found a code that open a file with this string: "C:\file.jpg/info"
I got an error when I try to open the file. I think the "/info" string is the problem, but the code I've read use that.
Can anyone explain me what is it for and why I'm having problems?
Thanks
Quote:Original post by MaxDemian
Hi, I found a code that open a file with this string: "C:\file.jpg/info"
*** Source Snippet Removed ***
I got an error when I try to open the file. I think the "/info" string is the problem, but the code I've read use that.
Can anyone explain me what is it for and why I'm having problems?
Thanks
umm... it's looking for a file info in C:\file.jpg\ and not finding it, I assume. Remove the /info.
you could have debugged this by printing the exact file location it was looking for. then you could have seen what the problem was. Consider outputting your data in this way next time, especially if its a large calculation (output the results of intermediate calculations) or building a string from substrings.
I found that dir must be a directory and /info is to get the information of the directory: Num of files, etc...
but still having errors
but still having errors
It's expecting there to actually be a file called "info" in the directory. You can have files without extensions, and this appears to be what it's looking for. If the file doesn't exist, you'll get an error with mode "r".
It's not some magical property of the file system that's going to give you info out of thin air.
It's not some magical property of the file system that's going to give you info out of thin air.
Quote:Original post by Nypyren
It's expecting there to actually be a file called "info" in the directory. You can have files without extensions, and this appears to be what it's looking for. If the file doesn't exist, you'll get an error with mode "r".
It's not some magical property of the file system that's going to give you info out of thin air.
So info is a file isnt it? then why "/info" and not "\info"?
PS: I've get code from here(page 3): http://cone3d.gamedev.net/pdfs/GFXwithSDLPart3.pdf
Quote:Original post by MaxDemianThe code in that article loads a file named 'info', which has been filled out by the author to contain settings/whatever.
PS: I've get code from here(page 3): http://cone3d.gamedev.net/pdfs/GFXwithSDLPart3.pdf
Quote:Original post by swiftcoderQuote:Original post by MaxDemianThe code in that article loads a file named 'info', which has been filled out by the author to contain settings/whatever.
PS: I've get code from here(page 3): http://cone3d.gamedev.net/pdfs/GFXwithSDLPart3.pdf
OK, but why "/" and not "\" ?
Quote:Original post by MaxDemianPresumably because the author was more familiar with unix/linux/mac, where '/' is the path separator. On Windows you will want to use '\' instead - but note carefully that in 'C:\file.jpeg\info', the character sequences '\f' and '\i' are escape codes, so you must escape the backslashes: 'C:\\file.jpeg\\info'.Quote:Original post by swiftcoderOK, but why "/" and not "\" ?Quote:Original post by MaxDemianThe code in that article loads a file named 'info', which has been filled out by the author to contain settings/whatever.
PS: I've get code from here(page 3): http://cone3d.gamedev.net/pdfs/GFXwithSDLPart3.pdf
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement