SIGSEV I can trace, but not fix (help needed)
I'm still having problems...here's my latest bit of code:
The above code seems to do....absolutely nothing. I'm still getting the same SIGSEV errors, which means that the file still is not being read. I feel like an idiot XD
-wyrmmage
Code:
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
fprintf(stderr, "Can't change to Resources direcory; something's seriously wrong\n");
exit(EXIT_FAILURE);
}
CFRelease(resourcesURL);
chdir(path);
FILE * readFile;
readFile = fopen("\\Objects\\objectManagers.txt","r+t");
if(readFile)
{
//!readFile.eof()
fscanf(readFile, "%d", &numberOfObjectManagers);
objectManager tempObjectManager;
for(int i=0; i<=numberOfObjectManagers; i++)
{
fscanf(readFile, "%s", managerNames[i]);
//managerNames[i] = "This is a test";
objectManagers[i] = tempObjectManager;
objectManagers[i].loadObjects(managerNames[i]);
}
fclose(readFile);
//write info to a file for debugging purposes
ofstream writeFile;
writeFile.open("\\Objects\\testWritingfile.txt");
if(writeFile.is_open())
{
writeFile << numberOfObjectManagers << "\n";
for(int x=0; x<=numberOfObjectManagers; x++)
{
writeFile << managerNames[x] << "\n";
}
writeFile.close();
}
}The above code seems to do....absolutely nothing. I'm still getting the same SIGSEV errors, which means that the file still is not being read. I feel like an idiot XD
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com/forum/
How about before you open the files you print the filename to the console? Print statements are a powerful means of debugging.
akb825 Wrote:How about before you open the files you print the filename to the console? Print statements are a powerful means of debugging.
I tried that...for the path variable, I get: /Users/eli/Desktop/MMORPG/MMORPG/build/MMORPG.app/Contents/Resources
This might be the problem...I just want to access folders that are inside /build/ , not inside the application itself. How exactly would I got about getting the location of the application, not the Resources folder of the application?
-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Just cut off the last 3 directories... The easiest way (if you have a C string) is to just start at the end and go back 3 slashes and put a NULL terminator in place of the third one. (assuming you have your own copy)
BTW, you should refrain from using a backslash (\) for Mac (or even Linux) stuff. That's really only used for Windows. Also, don't have a slash at the beginning of your path name when you have a relative path, because it will be treated as an absolute path. For example, you have
readFile = fopen("\\Objects\\objectManagers.txt","r+t");
That should read
readFile = fopen("Objects/objectManagers.txt","r+t");
BTW, you should refrain from using a backslash (\) for Mac (or even Linux) stuff. That's really only used for Windows. Also, don't have a slash at the beginning of your path name when you have a relative path, because it will be treated as an absolute path. For example, you have
readFile = fopen("\\Objects\\objectManagers.txt","r+t");
That should read
readFile = fopen("Objects/objectManagers.txt","r+t");
Just call CFBundleCopyBundleURL or whatever it's called instead of copying the resources URL...
Thanks for all of the help guys, you rock. Thanks to you, I finally got it going 
-wyrmmage

-wyrmmage
Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| What could be causing this SIGSEV? | Jones | 9 | 3,213 |
Jun 3, 2006 10:24 PM Last Post: PowerMacX |
|

