From: Rolf K. <lab...@us...> - 2006-01-08 22:52:35
|
Update of /cvsroot/opengtoolkit/lvzip/c_source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17303/c_source Modified Files: macbin.c macbin.h Log Message: More Mac fixes Index: macbin.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** macbin.c 8 Jan 2006 21:52:50 -0000 1.14 --- macbin.c 8 Jan 2006 22:52:26 -0000 1.15 *************** *** 10,13 **** --- 10,14 ---- #include "zlib.h" #include "ioapi.h" + #include "macbin.h" #if Mac *************** *** 33,38 **** #endif - #include "macbin.h" - extern void ZEXPORT DLLVersion(uChar* version) { --- 34,37 ---- *************** *** 176,180 **** extern MgErr ZEXPORT UtilFileInfo(Path path, uInt8 write, ! FileInfo *finderInfo, PStr comment, int32 *length) --- 175,179 ---- extern MgErr ZEXPORT UtilFileInfo(Path path, uInt8 write, ! LVFileInfo *finderInfo, PStr comment, int32 *length) *************** *** 238,242 **** err = PBSetCatInfoSync(&cpb); ! if (!err && *length && comment && PStrLen(comment)) { dtpb.ioDTReqCount = *length; err = PBDTSetCommentSync(&dtpb); --- 237,242 ---- err = PBSetCatInfoSync(&cpb); ! if (!err && *length && comment && PStrLen(comment)) ! { dtpb.ioDTReqCount = *length; err = PBDTSetCommentSync(&dtpb); *************** *** 302,424 **** #if Mac ! /* The following functions, IsAliasFile and ResolveAliasFileMountOption, are taken from ! Mac Tech Note #315. They may be used to resolve alias files quietly, without user ! interaction. ! */ ! static OSErr IsAliasFile(const FSSpec *fileFSSpec, ! Boolean *aliasFileFlag, ! Boolean *folderFlag) ! { ! CInfoPBRec myCInfoPBRec; ! OSErr err; ! ! if (fileFSSpec == NULL) ! return paramErr; ! ! if (aliasFileFlag) ! *aliasFileFlag ! if (folderFlag) ! *folderFlag = false; ! ! myCInfoPBRec.hFileInfo.ioCompletion = NULL; ! myCInfoPBRec.hFileInfo.ioNamePtr = (UPtr)fileFSSpec->name; ! myCInfoPBRec.hFileInfo.ioVRefNum = fileFSSpec->vRefNum; ! myCInfoPBRec.hFileInfo.ioDirID = fileFSSpec->parID; ! myCInfoPBRec.hFileInfo.ioFVersNum = 0; ! myCInfoPBRec.hFileInfo.ioFDirIndex = 0; ! ! err = PBGetCatInfoSync(&myCInfoPBRec); ! ! if (err == noErr) ! { ! if (folderFlag && (myCInfoPBRec.hFileInfo.ioFlAttrib & ioDirMask) != 0) ! *folderFlag = true; ! else if (aliasFileFlag && (myCInfoPBRec.hFileInfo.ioFlFndrInfo.fdFlags & 0x8000) != 0) ! *aliasFileFlag = true; ! } ! return err; ! } ! ! static OSErr ResolveAliasFileMountOption(FSSpec *fileFSSpec, ! Boolean resolveAliasChains, ! Boolean *targetIsFolder, ! Boolean *wasAliased, ! Boolean mountRemoteVols) { ! #define MAXCHAINS 10 ! ! short myResRefNum; ! Handle aliasHandle; ! FSSpec initFSSpec; ! Boolean updateFlag, foundFlag = false, wasAliasedTemp, specChangedFlag = false; ! short chainCount; ! OSErr err; ! ! if (fileFSSpec == NULL || wasAliased == NULL) ! return paramErr; ! ! initFSSpec = *fileFSSpec; ! chainCount = MAXCHAINS; ! ! if (targetIsFolder) ! *targetIsFolder = false; ! ! do ! { ! chainCount--; ! ! err = IsAliasFile(fileFSSpec, wasAliased, targetIsFolder); ! if (err != noErr || !(*wasAliased)) ! break; ! ! myResRefNum = FSpOpenResFile(fileFSSpec, fsCurPerm); ! err = ResError(); ! if (myResRefNum == -1) ! break; ! ! aliasHandle = Get1IndResource(rAliasType, 1); ! err = ResError(); ! if (aliasHandle == NULL) ! { ! CloseResFile(myResRefNum); ! break; ! } ! ! LoadResource(aliasHandle); ! err = ResError(); ! if (err != noErr) ! { ! CloseResFile(myResRefNum); ! break; ! } ! ! err = FollowFinderAlias(fileFSSpec, (AliasHandle)aliasHandle, mountRemoteVols, ! fileFSSpec, &updateFlag); ! ! if (err == noErr) ! { ! if (updateFlag) ! { ! ChangedResource(aliasHandle); ! WriteResource(aliasHandle); ! } ! ! specChangedFlag = true; ! ! err = IsAliasFile(fileFSSpec, &wasAliasedTemp, targetIsFolder); ! if (err == noErr) ! foundFlag = !(wasAliasedTemp && resolveAliasChains); ! } ! CloseResFile(myResRefNum); ! ! } while (err == noErr && chainCount > 0 && !foundFlag); ! ! if (err == noErr && !foundFlag) ! err = fnfErr; ! ! if (err != noErr && specChangedFlag) ! *fileFSSpec = initFSSpec; ! ! return err; } --- 302,314 ---- #if Mac ! static int32 LToPStr(LStrPtr lstr, PStr str) { ! int32 n = LStrLen(lstr); ! if (n > 255) ! n = 255; ! ps[0] = n; ! if (n) ! MoveBlock(LStrBuf(lstr), PStrBuf(str), n); ! return n; } *************** *** 440,444 **** err = MakeFSpec(0, 0, name, fss); if (err == noErr) ! err = ResolveAliasFileMountOption(fss, true, (Boolean*)&isDir, (Boolean*)&isAlias, false); } return err; --- 330,334 ---- err = MakeFSpec(0, 0, name, fss); if (err == noErr) ! err = ResolveAliasFileWithMountFlags(fss, true, (Boolean*)&isDir, (Boolean*)&isAlias, 0); } return err; Index: macbin.h =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** macbin.h 8 Jan 2006 21:32:22 -0000 1.8 --- macbin.h 8 Jan 2006 22:52:26 -0000 1.9 *************** *** 20,23 **** --- 20,27 ---- #endif + #if Mac + #include <MacTypes.h> + #endif + typedef char int8; typedef unsigned char uInt8; *************** *** 131,139 **** #endif ! typedef uChar Str255[256]; typedef const uChar ConstStr255[256]; - typedef uChar *PStr, *CStr; - #define PStrBuf(b) (&((PStr)(b))[1]) #define PStrLen(b) (((PStr)(b))[0]) /* # of chars in string */ --- 135,141 ---- #endif ! typedef uChar Str255[256], *PStr, *CStr; typedef const uChar ConstStr255[256]; #define PStrBuf(b) (&((PStr)(b))[1]) #define PStrLen(b) (((PStr)(b))[0]) /* # of chars in string */ *************** *** 145,148 **** --- 147,158 ---- } LStr, *LStrPtr, **LStrHandle; + #define LStrLen(p) ((p)->cnt) + #define LStrBuf(p) ((p)->str) + + typedef struct { + int32 cnt; + uChar str[256]; + } LStr256; + /* Typedefs */ typedef struct { *************** *** 158,162 **** uInt8 sId; /* Mac only */ uInt8 xFlags; /* Mac only */ ! } FileInfo; enum { openReadWrite, openReadOnly, openWriteOnly, openWriteOnlyTruncate }; /* open modes */ --- 168,172 ---- uInt8 sId; /* Mac only */ uInt8 xFlags; /* Mac only */ ! } LVFileInfo; enum { openReadWrite, openReadOnly, openWriteOnly, openWriteOnlyTruncate }; /* open modes */ *************** *** 177,181 **** extern MgErr ZEXPORT UtilFileInfo OF((Path path, uInt8 write, ! FileInfo *finderInfo, PStr comment, int32 *length)); --- 187,191 ---- extern MgErr ZEXPORT UtilFileInfo OF((Path path, uInt8 write, ! LVFileInfo *finderInfo, PStr comment, int32 *length)); |