ResKnife/External/MoreFiles/MoreFiles.c

1 line
17 KiB
C
Raw Normal View History

2002-03-29 14:59:03 +00:00
/* File: MoreFiles.c Contains: The long lost high-level and FSSpec File Manager functions. Version: MoreFiles Copyright: <09> 1992-2001 by Apple Computer, Inc., all rights reserved. You may incorporate this sample code into your applications without restriction, though the sample code has been provided "AS IS" and the responsibility for its operation is 100% yours. However, what you are not permitted to do is to redistribute the source as "DSC Sample Code" after having made changes. If you're going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple Sample Code, but that you've made changes. File Ownership: DRI: Apple Macintosh Developer Technical Support Other Contact: Apple Macintosh Developer Technical Support <http://developer.apple.com/bugreporter/> Technology: DTS Sample Code Writers: (JL) Jim Luther Change History (most recent first): <2> 2/7/01 JL Added standard header. Updated names of includes. <1> 12/06/99 JL MoreFiles 1.5. */ #include <MacTypes.h> #include <MacErrors.h> #include <Files.h> #define __COMPILINGMOREFILES #include "MoreFiles.h" #include "MoreFilesExtras.h" /*****************************************************************************/ pascal OSErr HGetVolParms(ConstStr255Param volName, short vRefNum, GetVolParmsInfoBuffer *volParmsInfo, long *infoSize) { HParamBlockRec pb; OSErr error; pb.ioParam.ioNamePtr = (StringPtr)volName; pb.ioParam.ioVRefNum = vRefNum; pb.ioParam.ioBuffer = (Ptr)volParmsInfo; pb.ioParam.ioReqCount = *infoSize; error = PBHGetVolParmsSync(&pb); if ( error == noErr ) { *infoSize = pb.ioParam.ioActCount; } return ( error ); } /*****************************************************************************/ pascal OSErr HCreateMinimum(short vRefNum, long dirID, ConstStr255Param fileName) { HParamBlockRec pb; pb.fileParam.ioNamePtr = (StringPtr)fileName; pb.fileParam.ioVRefNum = vRefNum; pb.ioParam.ioVersNum = 0; pb.fileParam.ioDirID = dirID; return ( PBHCreateSync(&pb) ); } /*****************************************************************************/ pascal OSErr FSpCreateMinimum(const FSSpec *spec) { return ( HCreateMinimum(spec->vRefNum, spec->parID, spec->name) ); } /*****************************************************************************/ pascal OSErr ExchangeFiles(short vRefNum, long srcDirID, ConstStr255Param srcName, long dstDirID, ConstStr255Param dstName) { HParamBlockRec pb; pb.fidParam.ioVRefNum = vRefNum; pb.fidParam.ioSrcDirID = srcDirID; pb.fidParam.ioNamePtr = (StringPtr)srcName; pb.fidParam.ioDestDirID = dstDirID; pb.fidParam.ioDestNamePtr = (StringPtr)dstName; return ( PBExchangeFilesSync(&pb) ); } /*****************************************************************************/ pascal OSErr ResolveFileIDRef(ConstStr255Param volName, short vRefNum, long fileID, long *parID, StringPtr fileName) { HParamBlockRec pb; OSErr error; Str255 tempStr; tempStr[0] = 0; if ( volName != NULL ) { BlockMoveData(volName, tempStr, volName[0] + 1); } pb.fidParam.ioNamePtr = (StringPtr)tempStr; pb.fidParam.ioVRefNum = vRefNum; pb.fidParam.ioFileID = fileID; error = PBResolveFileIDRefSync(&pb); if ( error == noErr ) { *parID = pb.fidParam.ioSrcDirID; if ( fileName != NULL ) { BlockMoveData(tempStr, fileName, tempStr[0] + 1); } } return ( error ); } /*****************************************************************************/ pascal OSErr FSpResolveFileIDRef(ConstStr255Param volName, short vRefNum, long fileID, FSSpec *spec) { OSErr error; error = DetermineVRefNum(volName, vRefNum, &(spec->vRefNum)); if ( error == noErr ) { error = ResolveFileIDRef(volName, vRefNum, fileID, &(spec->parID), spec->name); } return ( error ); } /*****************************************************************************/ pascal OSErr CreateFileIDRef(sh