Add file Create function

This commit is contained in:
Charles Lehner 2014-09-26 01:37:18 -04:00
parent c6b5221803
commit 3bd859aaa3

View File

@ -154,3 +154,26 @@ pascal OSErr SetFPos (short refNum, short posMode, long posOff)
pb.ioParam.ioPosOffset = posOff; pb.ioParam.ioPosOffset = posOff;
return PBSetFPosSync(&pb); return PBSetFPosSync(&pb);
} }
pascal OSErr Create (ConstStr255Param fileName, short vRefNum, OSType creator,
OSType fileType)
{
ParamBlockRec pb;
OSErr err;
memset(&pb, 0, sizeof(pb));
pb.fileParam.ioVRefNum = vRefNum;
pb.fileParam.ioNamePtr = (StringPtr)fileName;
// create the file
err = PBCreateSync(&pb);
if (err != noErr) return err;
// get previous finder info
err = PBGetFInfoSync(&pb);
if (err != noErr) return err;
// clear directory index
pb.fileParam.ioFDirIndex = 0;
// copy finder info words
pb.fileParam.ioFlFndrInfo.fdType = fileType;
pb.fileParam.ioFlFndrInfo.fdCreator = creator;
// save finder info
return PBSetFInfoSync(&pb);
}