home *** CD-ROM | disk | FTP | other *** search
- /****************************************/
-
- /* StripModule.c */
- /* Author: Shemin Gau, IP */
- /* Revision History: 03/24/94 */
-
- /****************************************/
-
-
- #include <Files.h>
- #include <string.h>
- #include <Memory.h>
- #include <ToolUtils.h>
- #include <Errors.h>
- #include <Packages.h>
- #include <Types.h>
- #include <OSUtils.h>
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
-
-
- pascal OSErr main(Str255 msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
- {
- SysEnvRec theWorld;
- CInfoPBRec pBlck;
- short volID;
- char pathName[256] ;
- char cDummy[128] ;
- Str255 pasDummy;
-
- char *str_holder = '\0';
- char *retstr = '\0';
- char *ctemp1;
- char *ctemp7;
- StringPtr ptemp1;
- FInfo fi;
-
- OSErr myErr = noErr;
- Boolean result = false;
-
-
- pathName[0] = '\0';
- cDummy[0] = '\0';
- pasDummy[0] = '\0';
-
- if (SysEnvirons(2, &theWorld)) {
- result = false;
- myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(myErr);
- } else {
- volID = theWorld.sysVRefNum;
- }
-
- /* set up pBlck stuff */
- pBlck.dirInfo.ioNamePtr = pasDummy;
- pBlck.dirInfo.ioVRefNum = volID;
- pBlck.dirInfo.ioFDirIndex = 1;
- pBlck.dirInfo.ioDrDirID = 0;
-
- /* get the first directory ID (if we can't, then errorback. */
- if ( PBGetCatInfo(&pBlck, false) != noErr ) {
- result = false;
- myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(myErr);
- }
-
- /* now, keep going up the tree things we reach the top */
- while (pBlck.dirInfo.ioDrDirID != 2) {
- /* swap id's from the parent ID to the current ID and reset the index. */
- pBlck.dirInfo.ioDrDirID = pBlck.dirInfo.ioDrParID;
- pBlck.dirInfo.ioFDirIndex = -1;
- /* get load the NamePtr (which is equal to pasDummy) and build the C string. */
- if (!PBGetCatInfo(&pBlck, false)) {
- ctemp1 = p2cstr(pasDummy);
- strcpy(cDummy, ctemp1);
- strcat(cDummy, ":");
- strcat(cDummy, pathName);
- strcpy(pathName, cDummy);
- } else {
- /* this is just in case the PB call fails. */
- result = false;
- myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(myErr);
- }
- }
-
- ctemp7 = p2cstr(msg);
- strcat(pathName, ctemp7);
-
- //now, convert the whole pathname into pascal string
- ptemp1 = c2pstr(pathName);
-
- if (GetFInfo(ptemp1, 0, &fi) != noErr) {
- result = false;
- myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(myErr);
- } else {
- result = true;
- myErr = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
- return(myErr);
- }
-
- }
-
-
- OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
- {
- Ptr p;
-
- if (p = NewPtr(theSize)) {
- BlockMove(theData, p, theSize);
-
- *outSize = theSize;
- *outMessage = p;
-
- return(noErr);
- } else {
- return(MemError());
- }
- }
-