void drawExampleName() { int left, top; Rect rect; Str255 label = "\pCurrent Example: "; Str255 name[9] = { "\p TRANSFER MODES", "\pARITHMETIC MODES", "\p DITHERING", "\p COLORIZATION", "\p COLOR MAPPING", "\p PAINT BUCKET", "\p LASSO TOOL", "\pPIXEL AVERAGING", "\p CUSTOM" }; Rect tempRect1; left = 15; top = GetPortBounds(GetWindowPort(gWindow), &tempRect1)->bottom - 13; drawName( left, top, label ); left += StringWidth( label ); SetRect( &rect, left - 2, top - 12, left + 130, top + 4 ); eraseRect( &rect ); drawName( left, top, name[(gCurrentExample / 10) - 1] ); } void drawTime( long ticks ) { Rect rect; int left, top; float seconds; char cString[40]; Rect tempRect1; GetPortBounds(GetWindowPort(gWindow), &tempRect1); left = tempRect1.right - 130; top = tempRect1.bottom - 13; SetRect( &rect, left - 2, top - 12, left + 90, top + 4 ); eraseRect( &rect ); seconds = (float)ticks / 60.0; sprintf( &cString[0], "Draw Time: %03.03f secs", seconds ); drawName( left, top, C2PStr( cString ) ); }
int chmod(char *path, int mode) { HParamBlockRec hpb; OSErr err; hpb.fileParam.ioNamePtr = C2PStr(path); hpb.fileParam.ioVRefNum = 0; hpb.fileParam.ioDirID = 0; if (mode & 0200) { err = PBHRstFLockSync(&hpb); } else { err = PBHSetFLockSync(&hpb); } if (err != noErr) { errno = err; return -1; } return 0; }
int destroy(char *path) { static char lastpath[NAME_MAX]; static FSSpec trashfolder; static Boolean FirstCall = true; static char Num = 0; static Boolean Immediate_File_Deletion = false; char currpath[NAME_MAX], *envptr; FSSpec fileToDelete; OSErr err; /* init this function */ if ((path == NULL) || (strlen(path) == 0)) { FirstCall = true; Num = 0; return -1; } UserStop(); RfDfFilen2Real(currpath, path, MacZip.MacZipMode, MacZip.DataForkOnly, &MacZip.CurrentFork); GetCompletePath(currpath,currpath,&fileToDelete, &err); if (FirstCall == true) { FirstCall = false; sstrcpy(lastpath,currpath); err = FSpFindFolder(fileToDelete.vRefNum, kTrashFolderType, kDontCreateFolder,&trashfolder); printerr("FSpFindFolder:",err,err,__LINE__,__FILE__,path); envptr = getenv("Immediate_File_Deletion"); if (!(envptr == (char *)NULL || *envptr == '\0')) { if (stricmp(envptr,"yes") == 0) Immediate_File_Deletion = true; else Immediate_File_Deletion = false; } if (Immediate_File_Deletion) { err = FSpDelete(&fileToDelete); return err; } err = CatMove (fileToDelete.vRefNum, fileToDelete.parID, fileToDelete.name, trashfolder.parID, trashfolder.name); return err; } if (strcmp(currpath,lastpath) == 0) { return 0; /* ignore, file is already deleted */ } else { if (Immediate_File_Deletion) { err = FSpDelete(&fileToDelete); sstrcpy(lastpath,path); return err; } err = CatMove (fileToDelete.vRefNum, fileToDelete.parID, fileToDelete.name, trashfolder.parID, trashfolder.name); /* -48 = file is already existing so we have to rename it before moving the file */ if (err == -48) { Num++; if (fileToDelete.name[0] >= 28) /* cut filename if to long */ fileToDelete.name[0] = 28; P2CStr(fileToDelete.name); sprintf(currpath,"%s~%d",(char *)fileToDelete.name,Num); C2PStr(currpath); C2PStr((char *)fileToDelete.name); err = HRename (fileToDelete.vRefNum, fileToDelete.parID, fileToDelete.name, (unsigned char *) currpath); err = CatMove (fileToDelete.vRefNum, fileToDelete.parID, (unsigned char *) currpath, trashfolder.parID, trashfolder.name); } } sstrcpy(lastpath,currpath); return err; }
void defineItems() { int i; int col, row; char tNames[numTItems][15] = { "srcCopy", "srcOr", "srcXor", "srcBic", "notSrcCopy", "notSrcOr", "notSrcXor", "notSrcBic" }; char aNames[numAItems][15] = { "blend", "addPin", "addOver", "subPin", "adMax", "subMin", "adMin", "transparent" }; char cNames[numCItems][15] = { "None", "Inverse", "FG Only", "BG Only" }; char dNames[numDItems][15] = { "Dithering OFF", "Dithering ON" }; char mNames[numMItems][15] = { "None", "Search Proc", "ColorTable" }; char bNames[numBItems][15] = { "White", "Black", "White&Black" }; char pNames[numPItems][15] = { "SeedCFill", "SeedFill" }; char lNames[numLItems][15] = { "CalcCMask", "CalcMask" }; Rect tempRect1; settings.bItem = 1; col = 15; row = GetPortBounds(GetWindowPort(gWindow), &tempRect1)->bottom - 157; for (i = 0; i < numTItems; i++) { strcpy(P2CStr(tItem[i].label),tNames[i]); C2PStr((char *)tItem[i].label); SetRect( &tItem[i].rect, col + 40, row + (i * 15), col + 40 + 90, row + ((i + 1) * 15) ); } for (i = 0; i < numAItems; i++) { strcpy(P2CStr(aItem[i].label),aNames[i]); C2PStr((char *)aItem[i].label); SetRect( &aItem[i].rect, col + 140, row + (i * 15), col + 140 + 90, row + ((i + 1) * 15) ); } for (i = 0; i < numCItems; i++) { strcpy(P2CStr(cItem[i].label),cNames[i]); C2PStr((char *)cItem[i].label); SetRect( &cItem[i].rect, col + 240, row + (i * 15), col + 240 + 90, row + ((i + 1) * 15) ); } for (i = 0; i < numDItems; i++) { strcpy(P2CStr(dItem[i].label),dNames[i]); C2PStr((char *)dItem[i].label); SetRect( &dItem[i].rect, col + 240, row + 90 + (i * 15), col + 240 + 90, row + 90 + ((i + 1) * 15) ); } for (i = 0; i < numMItems; i++) { strcpy(P2CStr(mItem[i].label),mNames[i]); C2PStr((char *)mItem[i].label); SetRect( &mItem[i].rect, col + 340, row + (i * 15), col + 340 + 90, row + ((i + 1) * 15) ); } for (i = 0; i < numBItems; i++) { strcpy(P2CStr(bItem[i].label),bNames[i]); C2PStr((char *)bItem[i].label); SetRect( &bItem[i].rect, col + 340, row + 75 + (i * 15), col + 340 + 90, row + 75 + ((i + 1) * 15) ); } for (i = 0; i < numPItems; i++) { strcpy(P2CStr(pItem[i].label),pNames[i]); C2PStr((char *)pItem[i].label); SetRect( &pItem[i].rect, col + 440, row + (i * 15), col + 440 + 90, row + ((i + 1) * 15) ); } for (i = 0; i < numLItems; i++) { strcpy(P2CStr(lItem[i].label),lNames[i]); C2PStr((char *)lItem[i].label); SetRect( &lItem[i].rect, col + 440, row + 60 + (i * 15), col + 440 + 90, row + 60 + ((i + 1) * 15) ); } }