mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-26 22:51:01 +00:00
Add some Files Manager glue functions (#4)
This commit is contained in:
parent
cd842777c9
commit
fda2e0a378
@ -20,6 +20,8 @@
|
||||
#include <MacMemory.h>
|
||||
#include <Files.h>
|
||||
#include <string.h>
|
||||
#include <Files.h>
|
||||
#include <Devices.h>
|
||||
|
||||
pascal Size GetPtrSize(Ptr ptr)
|
||||
{
|
||||
@ -61,3 +63,60 @@ pascal OSErr Eject (ConstStr63Param volName, short vRefNum)
|
||||
pb.volumeParam.ioVRefNum = vRefNum;
|
||||
return PBEject(&pb);
|
||||
}
|
||||
|
||||
pascal OSErr FSOpen (ConstStr255Param fileName, short vRefNum, short *refNum)
|
||||
{
|
||||
OSErr err;
|
||||
ParamBlockRec pb;
|
||||
memset(&pb, 0, sizeof(pb));
|
||||
pb.ioParam.ioNamePtr = (StringPtr)fileName;
|
||||
pb.ioParam.ioVRefNum = vRefNum;
|
||||
|
||||
// Try newer OpenDF first, because it does not open drivers
|
||||
err = PBOpenDFSync(&pb);
|
||||
if (err == paramErr) {
|
||||
// OpenDF not implemented, so use regular Open.
|
||||
err = PBOpenSync(&pb);
|
||||
}
|
||||
|
||||
*refNum = pb.ioParam.ioRefNum;
|
||||
return err;
|
||||
}
|
||||
|
||||
pascal OSErr OpenDF (ConstStr255Param fileName, short vRefNum, short *refNum)
|
||||
{
|
||||
return FSOpen(fileName, vRefNum, refNum);
|
||||
}
|
||||
|
||||
pascal OSErr FSClose (short refNum)
|
||||
{
|
||||
ParamBlockRec pb;
|
||||
memset(&pb, 0, sizeof(pb));
|
||||
pb.ioParam.ioRefNum = refNum;
|
||||
return PBCloseSync(&pb);
|
||||
}
|
||||
|
||||
pascal OSErr FSRead (short refNum, long *count, void *buffPtr)
|
||||
{
|
||||
OSErr err;
|
||||
ParamBlockRec pb;
|
||||
memset(&pb, 0, sizeof(pb));
|
||||
pb.ioParam.ioRefNum = refNum;
|
||||
pb.ioParam.ioBuffer = buffPtr;
|
||||
pb.ioParam.ioReqCount = *count;
|
||||
|
||||
err = PBReadSync(&pb);
|
||||
*count = pb.ioParam.ioActCount;
|
||||
return err;
|
||||
}
|
||||
|
||||
pascal OSErr GetEOF (short refNum, long *logEOF)
|
||||
{
|
||||
OSErr err;
|
||||
ParamBlockRec pb;
|
||||
memset(&pb, 0, sizeof(pb));
|
||||
pb.ioParam.ioRefNum = refNum;
|
||||
err = PBGetEOFSync(&pb);
|
||||
*logEOF = (long)pb.ioParam.ioMisc;
|
||||
return err;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user