Muffinking
2002.05.14, 09:39 PM
Since I porting my code over to carbon I really need to know how to do this..
As far as I know (from looking at apples site) all my function calls pretaining to file manipulation are useable in carbon..
yet it doesn't seem to work.. When I make an FSSpec to the file I want it returns an error that the file cannot be found or doesn't exist. Here is my code for opening my world Map:
void loadWorldNode(short theNode)
{
OSErr err;
FSSpec worldDatSpec;
long byteCount;
long startByte;
short fileRefNum;
// unsigned char namesting[] = {'W', 'o', 'r', 'l', 'd', ' ', 'M', 'a', 'p'};
//err = PBMakeFSSpecSync (paramBlock);
//The World Data Folder should be in the same folder
err = FSMakeFSSpec(0, 0, "\p:Senario Files:World Map", &worldDatSpec);
if(err)
{
switch(err)
{
case fnfErr: RedAlert("\pPut World Map in Senario folder."); break;
default: RedAlert("\pPut World Map in Senario folder."); break;
}
}
//Open the Data Fork of our File
err = FSpOpenDF(&worldDatSpec, fsRdWrPerm, &fileRefNum);
//Calculate where in the file to load from
startByte = sizeof(numGrid);
startByte *= theNode;
//Set the start position to where we need.
SetFPos (fileRefNum, fsFromStart, startByte);
//Read it all in at once
byteCount = sizeof(numGrid);
err = FSRead(fileRefNum, &byteCount, &numGrid);
//Close
err = FSClose(fileRefNum);
if(err != noErr) { RedAlert("\pError Closing File."); }
}
any Ideas on how to make it "see" my file?
As far as I know (from looking at apples site) all my function calls pretaining to file manipulation are useable in carbon..
yet it doesn't seem to work.. When I make an FSSpec to the file I want it returns an error that the file cannot be found or doesn't exist. Here is my code for opening my world Map:
void loadWorldNode(short theNode)
{
OSErr err;
FSSpec worldDatSpec;
long byteCount;
long startByte;
short fileRefNum;
// unsigned char namesting[] = {'W', 'o', 'r', 'l', 'd', ' ', 'M', 'a', 'p'};
//err = PBMakeFSSpecSync (paramBlock);
//The World Data Folder should be in the same folder
err = FSMakeFSSpec(0, 0, "\p:Senario Files:World Map", &worldDatSpec);
if(err)
{
switch(err)
{
case fnfErr: RedAlert("\pPut World Map in Senario folder."); break;
default: RedAlert("\pPut World Map in Senario folder."); break;
}
}
//Open the Data Fork of our File
err = FSpOpenDF(&worldDatSpec, fsRdWrPerm, &fileRefNum);
//Calculate where in the file to load from
startByte = sizeof(numGrid);
startByte *= theNode;
//Set the start position to where we need.
SetFPos (fileRefNum, fsFromStart, startByte);
//Read it all in at once
byteCount = sizeof(numGrid);
err = FSRead(fileRefNum, &byteCount, &numGrid);
//Close
err = FSClose(fileRefNum);
if(err != noErr) { RedAlert("\pError Closing File."); }
}
any Ideas on how to make it "see" my file?