/* ________ _______ _______ _______ _______ __ __ / ____ /\ / _____/\ / _____/\ / ___ /\ / ___ /\ / /\ / /\ / /\__/ / // /\____\// /\____\// /\_/ / // /\_/ / // / / / / / / /_/_/ / // /_/_ / / / / / // / // /_// / // /_/_/ / / / ____ / // ____/\ / / / / / // / // _____/ //_____ / / / /\__/ / // /\___\/ / / / / / // / // /\____\/ \____/ / / / / / / / // / / / /_/__ / /_// / // / / ______/ / / /_/ / / / //_/ / /______/\ /______/ //_/ / /_______/ / \_\/ \_\/ \_\/ \______\/ \______\/ \_\/ \_______\/ HYDRA - Tension/LSD AFCopy V4 is (C) 1993-4 Hydra/Tension/LSD This program was origonally written by me in PCQ Pascal, but I decided to rewrite this program to use lots of new workbench 2.x / 3.x fuctions after buying a lovely new Amiga 1200. :-) I just have to say, that after playing around with programming WB3.x I love it, it's SOoo easy with these tag doofers! MUCH better than defining loadsa structures, why people still support WB1.3 intuition beats me! And golly G O S H!! I *really* do like REQTOOLS!! >>>>>>>>>>>>> Fiddle Sticks! <<<<<<<<<<<<<< I hate it when hard disks crash, I've had to re-program a load of things back in since version 3.521 (20 revisions!) aarrgghhhhhh :-( things to do that have been done 1) add invisible requester to main window when doing something (such as when stat window is open or when user is editing config. --> dont need it. 2) make option for simple refresh window.. (to save mem, but induces slowdown when reorganizing windows.. :-( ) --> shit idea, do last!!! --> but might cure slowdown problem with OS 2.04!!! 3) add options for lines_per_side and make window vertical size modifyable. --> lines_per_side is now variable, but no option exists to change it once program has been started (yet) --> ok, it's possible to change it when the program is running now. but it still needs an option in the config. --> add code to resize window if it cant open with specified amount af lines.. --> added lines per side in config. all ok, i'll ad resize l8r 5) add adjustable colours (on directory/file items) --> filecol/dircol/highlightcol are variables and saved in config. still needs an option in the config section tho. --> ok, now saved in config file! 9) implement UG_CDC and UG_CDO (need to find what CurrentDir() Returns first) --> done now, but do i need it (i have the option to have it) on (un)arc 12) add file exists checking --> done --> added autooverwrite to config too.. 16) always update on rename --> done! 23) implement protect! --> done 28) add devicegads/usergads to edit config.. use a menu for this to save on code size (ie, you dont have to have another window with loads of gadget definitions...) --> idea! Create a window with two string inputs and a load of check gadgets for the batch flags! so when you select item from menu it comes up with the window. --> Do the same for the device gadgets but dont have check gadgets... --> used rtgetstrings instead.... 32) add auto overwrite to config. --> done 27) change filenames[] to pointers and allocate/free memory when needed. this will cut down on memory usage quite a bit and possibly allow for more files to be displayed in one directory. (IE fonts: !!!!) --> done! 15) make window open in middle of screen (or save position in config!) --> opens in the middle! 30) add option to ExecCommand() for async. --> done. 33) add ScreenToFront/Back on ExecCommand() --> done 11) add samevolume checking to SWAP command and if it is then do a rename... --> nope, just do a swap if a rename fails! --> done 35) add font requester for gadget fonts and filename fonts --> done! 34) possibly add more error checking to openmainscreen() --> done things to do.... (this list seems to get bigger and bigger!!!!) 6) start a notify on current directory, update (or ask to update) if it changes. --> Usefull for clone/rename/(un)archive/clone.... --> also have a notify on the current device so as to update disk free... 7) configureable middle gadgets. (to let user swap gadgets round) --> but is there any point... ? --> no ! 8) selection of archivers/archive name detection... --> kind of done, now recognised .ZIP files and use UNZIP still needs to be user-defineable tho.. 10) add amiga guide online help!! (shit, that'll take a while...) 13) disk inserted prompt - log to left/right or cancl --> maybe add sommat in config to enable/disable/automate this ? --> added! --> dont work if you insert a disk in PC0: or DF1: tho, only logs to df0:!!! 14) add keyboard support! (bollox that'll be a bummer!) --> all comands can be done with keyboard --> just add file selection and highlighting now.. 17) add double click routine, and programmable file types. --> that'll take some time :-) --> do for version 4.x me thinks!! --> double click to change dir is added, but not the programmable file types this is a feature i may add in afcopy pro but not in v4 18) add size directory when double click on dirname. --> rather cool idea!! --> can't be double click, but maybe a menu option ? 19) add ZipWindow() hotkey --> nope, use YAK instead!! (heheee) 20) save ZoomCoords in config! 21) save window coords in config 22) possibly add fuction in loadconfig for reading in the integers so as to save on code size.. 26) add use and cancel gadgets to config. make closewindow same as cancel --> Nah... 29) update disk free when copying files (but have an option for this so as not to cause slowdown when using floppies!) 31) add option to rename old or new file when copying file and destination file exists 32) add option to rename so that you can choose to rename the icon for the highlighted file too.. 36) reactivate window after executing an external command (much in the same way as ShuffleScreens at the moment.) 37) add process indicator things to fix 1) fix add icon routine on adding file to end of list.. --> seems to be OK now. perhaps was due to compiler/linker ?? --> nope, now i've got MMU i can run enforcer and have found that afcopy causes a hit on the filecopy routine on the makedir bit. --> done, turns out that the bug was in the checkstatcancel checking for a click on a gadget in a window that wasnt opened!! 2) fix bug when window is redrawn and sliders werent at the top.. --> done */ /* Not TOO many include files... (honest!!) */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* for the correct PATH settings when run from WB */ #include #include #include #include #include #include #include #include #include /* tell compiler vars in afcopyvars.h are NOT external. */ #define MAIN #include "username.h" #include "afcopy_defines.h" /* defines */ #include "afcopy_protos.h" /* prototypes */ #include "afcopy_vars.h" /* variables */ #include "afcopy_version.h" /* version defines */ extern char *versionstring; long __stack = 40000; /* for recursive directory stuff.... */ /* and lots of it toooo */ /* if you wanna test the max stack then goto ram:t in one window and ram: in the other then in the ram: window select the dir t and copy it to the other window... :-) */ ULONG last_sec=0,last_mic=0; LONG last_x=0,last_y=0; void errormsg(char *errormsgstr) { rtEZRequest (errormsgstr,okmsg,NULL,(struct TagItem *)&reqtags,NULL); } /* * Okay, lets get started with the coding now... * Please note all the sarcastic/patronising/funny comments on the rtEZRequest's!! * well, *I* like them even if you dont! :-) */ void strfcat(char *dest, char *source, int destlen) { int pos=0,where=strlen(dest); while (where+pos0 && l2>0 ;l1--,l2--); if (l2==0 && whole[l1]==match[l2]) return(TRUE); else return(FALSE); } BOOL iendofstring(char *whole,char *match) { short l1,l2; for (l1=strlen(whole)-1,l2=strlen(match)-1; toupper(whole[l1])==toupper(match[l2]) && l1>0 && l2>0 ;l1--,l2--); if (l2==0 && toupper(whole[l1])==toupper(match[l2])) return(TRUE); else return(FALSE); } /* this routine checks if memory has been allocated for a filename, if not it`ll * allocate it for us. */ BOOL allocmemforname(int side) { if (totalfiles[side]+1>allocated[side]) { if (filename[side][totalfiles[side]]=AllocMem(MAX_FILE_LEN+1,MEMF_PUBLIC)) { allocated[side]++; } } if (allocated[side]>totalfiles[side]) return(TRUE); else return(FALSE); } /* this routine adds a filename to the bottom of the file list, it`ll allocate memory * for the name too. */ BOOL AddToFileList(int side,char *fname,LONG size,LONG type,BYTE tags) { if (totalfiles[side]=0 && type!=0 && allocmemforname(side)) { strcpy(filename[side][totalfiles[side]],fname); filesize[side][totalfiles[side]]=size; filetype[side][totalfiles[side]]=type; filetags[side][totalfiles[side]]=tags; totalfiles[side]++; return(TRUE); } else { return(FALSE); } } /* display a single filename and size in the correct colours * at position y down the screen on the specified side. */ /* this is the old one, the new one seems a BIT quicker.. (see below) */ void displaysinglefile(int side,int ypos,int start) { short l; if (filetags[side][start]==TRUE) { SetBPen(W->RPort,highlightcol); } else { SetBPen(W->RPort,NORMALCOL); } if (filetype[side][start]>0) { strcpy(dummystring,""); SetAPen(W->RPort,dircol); } else { stci_d(dummystring,filesize[side][start]); SetAPen(W->RPort,filecol); } l=32-strlen(dummystring); strncpy(outputstring,filename[side][start],l); strpad(outputstring,l); strcat(outputstring,dummystring); Move(W->RPort,filexpos[side]+2,topborder+FILEYPOS+FONTBASELINE+(FILEHEIGHT*ypos)); Text(W->RPort,outputstring,strlen(outputstring)); } /* void displaysinglefile(int side,int ypos,int start) { short l; int y=topborder+1+FILEYPOS+(FILEHEIGHT*ypos)-1; if (filetags[side][start]==TRUE) { SetBPen(W->RPort,highlightcol); SetAPen(W->RPort,highlightcol); } else { SetBPen(W->RPort,NORMALCOL); SetAPen(W->RPort,NORMALCOL); } RectFill(W->RPort,filexpos[side]+2,y, filexpos[side]+FILEWIDTH-1,y+FILEHEIGHT-1); if (filetype[side][start]>0) { strcpy(dummystring,""); SetAPen(W->RPort,dircol); } else { stci_d(dummystring,filesize[side][start]); SetAPen(W->RPort,filecol); } Move(W->RPort,filexpos[side]+2,y+FONTBASELINE); Text(W->RPort,filename[side][start],strlen(filename[side][start])); l=strlen(dummystring); Move(W->RPort,(filexpos[side]+FILEWIDTH)-(l*8),y+FONTBASELINE); Text(W->RPort,dummystring,l); } */ /* this routine clears the are of the screen where a filename would have been * */ void wipefile(int side,int ypos) { SetAPen(W->RPort,0); SetBPen(W->RPort,0); RectFill(W->RPort,filexpos[side],topborder+1+FILEYPOS+(FILEHEIGHT*ypos)-1, filexpos[side]+FILEWIDTH+1,topborder+FILEYPOS+(FILEHEIGHT*(ypos+1))-1); } /* displays the list of filenames on specified side starting from the specified offset * */ void displayfilelist(int side,int start) { int loop=0; /* clearside(side); */ SetAPen(W->RPort,1); SetAPen(W->RPort,0); while (loopRPort,2); SetBPen(W->RPort,0); OutTextXY(W,filexpos[side]+2,FONTBASELINE+topborder+3,dummystring); } void selected(short side, int loop, BOOL yn) { if (!(filetags[side][loop]==yn)) { if (yn) { selectedfiles[side]++; selectedsize[side]+=filesize[side][loop]; } else { selectedfiles[side]--; selectedsize[side]-=filesize[side][loop]; } filetags[side][loop]=yn; updateselected(side); } } /* turns on and off the tags or reverses them. * */ void setmarks(int side,int action) { int loop; selectedfiles[side]=0; selectedsize[side]=0; for (loop=0;loopPlease< contact me on any cool UK BBS\n" "so that I can fix em and make it better!", "Fair Enough!",NULL,NULL, RTGS_Flags, GSREQF_CENTERTEXT,RT_Window,W,TAG_END); } /* check to see if the CANCEL gadget has been pressed * */ int CheckStatCancel(void) { struct IntuiMessage *imsg; struct Gadget *gad; int err=0; if (statw) /* check window is open first!!! */ /* this is the fix to the MakeDir() bug!!! */ { if ((imsg = GT_GetIMsg(statw->UserPort))) { if (imsg->Class == IDCMP_GADGETUP) { gad=(struct Gadget *)imsg->IAddress; if (gad->GadgetID==G_StatCancel) { err=1; } } GT_ReplyIMsg(imsg); } } return(err); } /* update the staus window with the filename and path(s) of the files being worked on * */ void UpdateStat(char *functionstr,char *fromstr,char *tostr,char *fname) { char outstr[74]; OutTextXY(statw,8,topborder+15+FONTBASELINE,functionstr); strncpy(outstr,fromstr,73); strpad(outstr,73); outstr[72]='\0'; OutTextXY(statw,8,topborder+15+9+FONTBASELINE,outstr); strncpy(outstr,tostr,73); strpad(outstr,73); outstr[72]='\0'; OutTextXY(statw,8,topborder+15+18+FONTBASELINE,outstr); strncpy(outstr,fname,73); strpad(outstr,73); outstr[72]='\0'; OutTextXY(statw,8,topborder+15+27+FONTBASELINE,outstr); DrawBevelBox(statw->RPort,5,topborder+12,STATWIDTH-10,42,GT_VisualInfo,vi,TAG_DONE); } /* checks to see if fname1 is in the same dir as dirname * E.g. fname="sys:hydra/data.iff" dirname="sys:hydra" returns true! */ int SameDir(char *fname1,char *dirname) { char tempstr[MAX_PATH_LEN+1]; strcpy(tempstr,fname1); getparent(tempstr); addterm(tempstr); if (!stricmp(tempstr,dirname)) return(TRUE); else return(FALSE); } /* * */ void Updatedisplay(int side) { updatepath(side); qsortfiles(side,0,totalfiles[side]-1); updateslider(side); displayfilelist(side,displayoffset[side]); DoDiskInfo(side,cpath[side]); updateselected(side); } void FreeNameList(struct List *FileList) { struct Node *Current,*Next; if (Current=FileList->lh_Head) { while (FileList->lh_Head->ln_Succ) { Next=Current->ln_Succ; if (Current->ln_Name) { free(Current->ln_Name); } Remove(Current); FreeMem(Current,sizeof(struct Node)); Current=Next; } } } struct Node *NewNameNode(struct List *NameList,char *str) { struct Node *new=NULL; if (new=AllocMem(sizeof(struct Node),MEMF_PUBLIC)) { new->ln_Name=strdup(str); AddTail(NameList,new); } return(new); } void dofuncerror(char *errorstr) { Errors++; // do NOT relate ERRORS to nodes in list when in CMDline mode NewNameNode(ErrorList,errorstr); GT_SetGadgetAttrs(statgads[G_ErrorList], statw, NULL, GTLV_Labels, ErrorList, GTLV_Top, Errors-1, // errors is always > 0 if this is called! TAG_END); } void DosError(char *msg,char *msg2,int errnum) { char errmsg[401],iomsg[50]; /* allocate plenty of room */ IoErrMsg(iomsg,errnum); strcpy(errmsg,msg2); strfcat(errmsg," ",400); strfcat(errmsg,iomsg,400); dofuncerror(errmsg); } struct Gadget *createProtGadgets(struct Gadget **glistptr, void *vi, UWORD topborder, struct Gadget *gads[]) { struct NewGadget ng; struct Gadget *gad; gad = CreateContext(glistptr); ng.ng_LeftEdge = 5; ng.ng_TopEdge = 1+topborder; ng.ng_Width = 8; ng.ng_Height = 10; ng.ng_TextAttr = &ScreenFontAttr; ng.ng_VisualInfo = vi; ng.ng_Flags = PLACETEXT_RIGHT; ng.ng_GadgetID = G_p_d; ng.ng_GadgetText = "Delete"; gads[G_p_d] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,GTCB_Checked,TRUE,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_e; ng.ng_GadgetText = "Execute"; gads[G_p_e] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,GTCB_Checked,TRUE,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_w; ng.ng_GadgetText = "Write"; gads[G_p_w] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,GTCB_Checked,TRUE,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_r; ng.ng_GadgetText = "Read"; gads[G_p_r] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,GTCB_Checked,TRUE,TAG_END); ng.ng_LeftEdge = 105; ng.ng_TopEdge = 1+topborder; ng.ng_GadgetID = G_p_a; ng.ng_GadgetText = "Archived"; gads[G_p_a] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_s; ng.ng_GadgetText = "Script"; gads[G_p_s] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_p; ng.ng_GadgetText = "Pure"; gads[G_p_p] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,TAG_END); ng.ng_TopEdge += ng.ng_Height+2; ng.ng_GadgetID = G_p_h; ng.ng_GadgetText = "Hidden"; gads[G_p_h] = gad = CreateGadget(CHECKBOX_KIND, gad, &ng,TAG_END); return(gad); } struct Window *OpenProtWindow(void) { return(OpenWindowTags(NULL, WA_Left,W->LeftEdge+210, WA_Top,W->TopEdge+50, WA_Height,65, WA_Width,220, WA_AutoAdjust, FALSE, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_CloseGadget, TRUE, WA_SimpleRefresh, FALSE, WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY, WA_Title,"File Protection Bits", WA_PubScreen, mysc, WA_Gadgets,protglist, TAG_END)); } int EditProt( void ) /* returns -1 if failed or cancelled.. */ { struct IntuiMessage *imsg; BOOL done=FALSE; int prot=0; if (createProtGadgets(&protglist, vi, topborder,protgads)) { if ((protw=OpenProtWindow())) { do { Wait (1 << protw->UserPort->mp_SigBit); if ((imsg = GT_GetIMsg(protw->UserPort))) { if (imsg->Class == IDCMP_CLOSEWINDOW) { done=TRUE; } GT_ReplyIMsg(imsg); } } while (!done); CloseWindow(protw); if (!(protgads[G_p_d] ->Flags & GFLG_SELECTED)) prot+=1; if (!(protgads[G_p_e] ->Flags & GFLG_SELECTED)) prot+=2; if (!(protgads[G_p_w] ->Flags & GFLG_SELECTED)) prot+=4; if (!(protgads[G_p_r] ->Flags & GFLG_SELECTED)) prot+=8; if (protgads[G_p_a] ->Flags & GFLG_SELECTED) prot+=16; if (protgads[G_p_p] ->Flags & GFLG_SELECTED) prot+=32; if (protgads[G_p_s] ->Flags & GFLG_SELECTED) prot+=64; if (protgads[G_p_h] ->Flags & GFLG_SELECTED) prot+=128; } FreeGadgets(protglist); } if (!done) return(-1); else return(prot); /* done will be false if window didnt open or cadgets weren't created. */ } /* returns the amount of files on a specified side that have been selected * by the user */ int AmountTagged(int side) { int loop; int retval=0; for (loop=0;loopUserPort)) { gad = (struct Gadget *)imsg->IAddress; imsgClass = imsg->Class; imsgCode = imsg->Code; GT_ReplyIMsg(imsg); switch(imsgClass) { case IDCMP_REFRESHWINDOW: GT_BeginRefresh(W); GT_EndRefresh(W, TRUE); UpdateMainWindow(); break; case IDCMP_NEWSIZE: iconised=!iconised; if (!iconised) { UpdateMainWindow(); } break; } } } void Dofunction(int mode,int side) { int errnum=0,loop=0,myprot=-1,where; BOOL doall=FALSE,ok=FALSE,done=FALSE,cancel=FALSE,ignorebatcherrors; int ReadDir=DF_READNONE; int otherside=1-side; char arcname[MAX_PATH_LEN+1],pathstr[MAX_PATH_LEN+1],tmpstr[MAX_PATH_LEN+1]; FILE *arcfile=NULL; BPTR FL; tempautooverwrite=FALSE; skipall=FALSE; Errors=0; if (ErrorList=AllocMem(sizeof(struct List),MEMF_ANY)) { NewList(ErrorList); if (AmountTagged(side)>0) { switch (mode) { case G_Clone: case G_Swap: case G_Copy: if (pathok[side] && pathok[otherside]) ok=TRUE; break; case G_Delete: if (pathok[side]) ok=!deleteverify || rtEZRequest("Are you sure you\n want me to delete\nthese files ?","_Yeah, Nuke Em!|_No, Stop!",NULL,(struct TagItem *)&reqtags,NULL); /* Clever bit of coding on the above line!!! (think about it!!!) */ break; case G_Archive: strcpy(arcname,cpath[otherside]); if ((pathok[side]) && (rtGetString (arcname, MAX_PATH_LEN, "Enter Archive Name", NULL,RT_Window,W, TAG_END)) && (arcname[0]!='\0') ) { ok=TRUE; } break; case G_Rename: case G_View: case G_Read: case G_Edit: case G_Hear: case G_Info: case G_Execute: case G_Run: case G_Comment: case G_Unarc: if (pathok[side]) ok=TRUE; break; case G_Batch: if (rtGetString(batchstring,MAX_COMMAND_LEN,"Batch",NULL, RTGS_TextFmt,"Enter Batch String\n" "Use @F@ for full filename\n" "@N@ for name\n" "@E@ for extension\n" "@<@ for current side\n" "@>@ for other side\n\n" "see instructions\n" "for more details", RTGS_Flags, GSREQF_CENTERTEXT, RT_Window,W, TAG_END)) { ignorebatcherrors=rtEZRequest("Ignore Errors Between Programs ?","_Yup!|_Nope",NULL,(struct TagItem *)&reqtags,NULL); ok=TRUE; } break; case G_Userleft0: case G_Userleft1: case G_Userleft2: case G_Userleft3: case G_Userleft4: case G_Userleft5: case G_Userleft6: case G_Userleft7: case G_Userleft8: case G_Userleft9: case G_Userleft10: case G_Userleft11: case G_Userleft12: case G_Userleft13: case G_Userleft14: if (usergadflags[0][mode-G_Userleft0]!=0) { if (usergadflags[0][mode-G_Userleft0] & UG_SENDFILES) { ok=TRUE; } else { if (usergadflags[0][mode-G_Userleft0] & UG_CDC) cdto(cpath[side]); if (usergadflags[0][mode-G_Userleft0] & UG_CDO) cdto(cpath[otherside]); ExecCommand(usergadactual[0][mode-G_Userleft0],(usergadflags[0][mode-G_Userleft0] & UG_ASYNCH > 0) ? TRUE : FALSE, (usergadflags[0][mode-G_Userleft0] & UG_SHUFFLE > 0) ? TRUE : FALSE ); ReadDir=0; if (usergadflags[0][mode-G_Userleft0] & UG_READC) ReadDir+=DF_READCURRENT; if (usergadflags[0][mode-G_Userleft0] & UG_READO) ReadDir+=DF_READOTHER; } } break; case G_Userright0: case G_Userright1: case G_Userright2: case G_Userright3: case G_Userright4: case G_Userright5: case G_Userright6: case G_Userright7: case G_Userright8: case G_Userright9: case G_Userright10: case G_Userright11: case G_Userright12: case G_Userright13: case G_Userright14: if (usergadflags[1][mode-G_Userright0]!=0) { if (usergadflags[1][mode-G_Userright0] & UG_SENDFILES) { ok=TRUE; } else { if (usergadflags[1][mode-G_Userright0] & UG_CDC) cdto(cpath[side]); if (usergadflags[1][mode-G_Userright0] & UG_CDO) cdto(cpath[otherside]); ExecCommand(usergadactual[1][mode-G_Userright0],(usergadflags[1][mode-G_Userright0] & UG_ASYNCH) > 0 ? TRUE : FALSE, (usergadflags[1][mode-G_Userright0] & UG_SHUFFLE) > 0 ? TRUE : FALSE ); ReadDir=0; if (usergadflags[1][mode-G_Userright0] & UG_READC) ReadDir+=DF_READCURRENT; if (usergadflags[1][mode-G_Userright0] & UG_READO) ReadDir+=DF_READOTHER; } } break; case G_Protect: myprot=EditProt(); if (myprot!=-1) ok=TRUE; break; } if (ok) { if (createStatGadgets(&statglist, vi, topborder,statgads)) { if ((statw=OpenStatWindow())) { DrawBevelBox(statw->RPort,5,topborder+12,STATWIDTH-10,42,GT_VisualInfo,vi,TAG_DONE); SetFont(statw->RPort,ScreenFont); SetAPen(statw->RPort,2); if (pathok[side]) { do { handlerefresh(); if (filetags[side][loop] && !(cancel=CheckStatCancel()) ) { strcpy(pathstr,cpath[side]); addterm(pathstr); strfcat(pathstr,filename[side][loop],MAX_PATH_LEN); /** pathstr contains path+filename of currentfile **/ strcpy(tmpstr,cpath[otherside]); addterm(tmpstr); strfcat(tmpstr,filename[side][loop],MAX_PATH_LEN); /** tmpstr contains otherside's path+filename of currentfile **/ switch(mode) /* for filetype independant functions */ { case G_Protect: UpdateStat("Protect",cpath[side],"",filename[side][loop]); errnum=SetProtection(pathstr,myprot); if (!errnum) DosError("Error Protecting File",pathstr,errnum); break; case G_View: UpdateStat("View",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_View],side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Viewing File",pathstr,errnum); break; case G_Read: UpdateStat("Read",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Read],side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Reading File",pathstr,errnum); break; case G_Edit: UpdateStat("Edit",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Edit],side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Editing File",pathstr,errnum); break; case G_Hear: UpdateStat("Hear",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Hear],side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Hearing File",pathstr,errnum); break; case G_Info: strcpy(tmpstr,filename[side][loop]); if ((where=iposition(".INFO",tmpstr))>=0) { tmpstr[where]=0; // remove .INFO from string. } if (FL=Lock(cpath[side],ACCESS_READ)) { WBInfo(FL,tmpstr,mysc); UnLock(FL); } break; case G_Execute: UpdateStat("Execute Script",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Execute],side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Executing Script",pathstr,errnum); break; case G_Run: UpdateStat("Run Program",cpath[side],"",filename[side][loop]); strcpy(tmpstr,"\""); strcat(tmpstr,pathstr); strcat(tmpstr,"\""); if (errnum=rtGetString (tmpstr, MAX_PATH_LEN, "Modify Command Line", NULL, RTGS_GadFmt, "Run|Run Asynch|Cancel", RT_Window,W, TAG_END)) { errnum=ExecCommand(tmpstr,errnum==2 ? TRUE : FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Running Program",pathstr,errnum); } else { cancel=TRUE; } break; case G_Archive: UpdateStat("Creating Archive File List",cpath[side],"",filename[side][loop]); if (!arcfile) /* is file open */ { /* No, then open it */ if ((arcfile=fopen("T:AFCopy.tmp","w"))==NULL) { errnum=IoErr(); if (errnum) DosError("Error Create Arc Temp File","T:AFCopy.TMP",errnum); } } if (arcfile) /* is file open */ { fprintf(arcfile,"%s\n",filename[side][loop]); /* add filename to arcfile */ } break; case G_Unarc: UpdateStat("Un-Archive",cpath[side],"",filename[side][loop]); cdto(cpath[otherside]); if (iendofstring(filename[side][loop],".zip")) { strcpy(arcname,"unzip \""); } else { strcpy(arcname,CommandString[C_Unarc]); strfcat(arcname," x \"",MAX_PATH_LEN); } strfcat(arcname,pathstr,MAX_PATH_LEN); strfcat(arcname,"\"",MAX_PATH_LEN); // strfcat(arcname,cpath[otherside],MAX_PATH_LEN); // strfcat(arcname,"\"",MAX_PATH_LEN); if (rtGetString (arcname, MAX_PATH_LEN, "Modify Command Line", NULL,RT_Window,W, TAG_END)) { ReadDir=DF_READOTHER; errnum=ExecCommand(arcname,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Running Unarchiver",CommandString[C_Unarc],errnum); } break; case G_Batch: UpdateStat("Command Batch",cpath[side],"",filename[side][loop]); createstring(tmpstr,batchstring,side,otherside,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !ignorebatcherrors) DosError("Error Running Program",pathstr,errnum); break; case G_Userleft0: case G_Userleft1: case G_Userleft2: case G_Userleft3: case G_Userleft4: case G_Userleft5: case G_Userleft6: case G_Userleft7: case G_Userleft8: case G_Userleft9: case G_Userleft10: case G_Userleft11: case G_Userleft12: case G_Userleft13: case G_Userleft14: UpdateStat("User Command",usergadnames[0][mode-G_Userleft0],"",filename[side][loop]); strcpy(tmpstr,usergadactual[0][mode-G_Userleft0]); if (usergadflags[0][mode-G_Userleft0] & UG_SENDFILES) { createstring(tmpstr,tmpstr,side,otherside,loop,CS_ALL); } else { createstring(tmpstr,tmpstr,side,otherside,loop,CS_NOFILES); } if (usergadflags[0][mode-G_Userleft0] & UG_MODIFY) { if (!rtGetString (tmpstr, MAX_PATH_LEN, "Modify Command Line", NULL,RT_Window,W, TAG_END)) cancel=TRUE; } if (!cancel) { if (usergadflags[0][mode-G_Userleft0] & UG_CDC) cdto(cpath[side]); if (usergadflags[0][mode-G_Userleft0] & UG_CDO) cdto(cpath[otherside]); errnum=ExecCommand(tmpstr,(usergadflags[0][mode-G_Userleft0] & UG_ASYNCH) > 0 ? TRUE : FALSE, (usergadflags[0][mode-G_Userleft0] & UG_SHUFFLE) > 0 ? TRUE : FALSE ); if (errnum && !nomessages) DosError("Error Running Program",pathstr,errnum); else { ReadDir=0; if (usergadflags[0][mode-G_Userleft0] & UG_READC) ReadDir+=DF_READCURRENT; if (usergadflags[0][mode-G_Userleft0] & UG_READO) ReadDir+=DF_READOTHER; } } break; case G_Userright0: case G_Userright1: case G_Userright2: case G_Userright3: case G_Userright4: case G_Userright5: case G_Userright6: case G_Userright7: case G_Userright8: case G_Userright9: case G_Userright10: case G_Userright11: case G_Userright12: case G_Userright13: case G_Userright14: UpdateStat("User Command",usergadnames[1][mode-G_Userright0],"",filename[side][loop]); strcpy(tmpstr,usergadactual[1][mode-G_Userright0]); if (usergadflags[1][mode-G_Userright0] & UG_SENDFILES) { createstring(tmpstr,tmpstr,side,otherside,loop,CS_ALL); } else { createstring(tmpstr,tmpstr,side,otherside,loop,CS_NOFILES); } if (usergadflags[1][mode-G_Userright0] & UG_MODIFY) { if (!rtGetString (tmpstr, MAX_PATH_LEN, "Modify Command Line", NULL,RT_Window,W, TAG_END)) cancel=TRUE; } if (!cancel) { if (usergadflags[1][mode-G_Userright0] & UG_CDC) cdto(cpath[side]); if (usergadflags[1][mode-G_Userright0] & UG_CDO) cdto(cpath[otherside]); errnum=ExecCommand(tmpstr,(usergadflags[1][mode-G_Userright0] & UG_ASYNCH) > 0 ? TRUE : FALSE, (usergadflags[1][mode-G_Userright0] & UG_ASYNCH) > 0 ? TRUE : FALSE ); if (errnum && !nomessages) DosError("Error Running Program",pathstr,errnum); else { ReadDir=0; if (usergadflags[1][mode-G_Userright0] & UG_READC) ReadDir+=DF_READCURRENT; if (usergadflags[1][mode-G_Userright0] & UG_READO) ReadDir+=DF_READOTHER; } } break; case G_Rename: UpdateStat("Rename",cpath[side],"",filename[side][loop]); strcpy(tmpstr,pathstr); if (rtGetString (tmpstr, MAX_PATH_LEN, "Enter New Name", NULL,RT_Window,W, TAG_END)) { if (strcmp(tmpstr,pathstr)!=0) { Rename(pathstr,tmpstr); errnum=IoErr(); if (errnum) DosError("Error Renaming File",pathstr,errnum); else { ReadDir=DF_READCURRENT; } } } break; case G_Comment: UpdateStat("Comment File",cpath[side],"",filename[side][loop]); errnum=ModifyComment(pathstr,doall); if (errnum==-1) doall=TRUE; if (errnum>0) DosError("Error Commenting File",pathstr,errnum); break; } if (filetype[side][loop]<0) /* is it a DIR or a FILE */ { /* FILE */ switch(mode) { case G_Delete: UpdateStat("Delete",cpath[side],"",filename[side][loop]); errnum=filenuke(pathstr); if (errnum) DosError("Error Deleting File",pathstr,errnum); else ReadDir=DF_READCURRENT; break; case G_Copy: UpdateStat("Copy",cpath[side],cpath[otherside],filename[side][loop]); errnum=filecopy(pathstr,tmpstr); if (errnum) DosError("Error Copying File",pathstr,errnum); else { ReadDir=DF_READOTHER; } break; case G_Clone: UpdateStat("Clone",cpath[side],cpath[otherside],filename[side][loop]); if (rtGetString (tmpstr, MAX_PATH_LEN, "Enter Clone Name", NULL,RT_Window,W, TAG_END)) { if (stricmp(pathstr,tmpstr)!=0) { errnum=filecopy(pathstr,tmpstr); if (errnum) DosError("Error Cloning File",pathstr,errnum); else { ReadDir=DF_READOTHER; } } } break; case G_Swap: UpdateStat("Swap",cpath[side],cpath[otherside],filename[side][loop]); errnum=fileswap(pathstr,tmpstr); if (errnum) DosError("Error Swapping File",pathstr,errnum); ReadDir=DF_READBOTH; break; } } else { /* DIR */ switch(mode) { case G_Delete: UpdateStat("Delete",cpath[side],"",filename[side][loop]); errnum=DirFunc(pathstr,NULL,mode); if (errnum) DosError("Error Deleting Directory",pathstr,errnum); else ReadDir=DF_READCURRENT; break; case G_Copy: UpdateStat("Copy",cpath[side],cpath[otherside],filename[side][loop]); errnum=DirFunc(pathstr,tmpstr,mode); if (errnum) DosError("Error Copying Directory",pathstr,errnum); ReadDir=DF_READOTHER; break; case G_Clone: UpdateStat("Copy",cpath[side],cpath[otherside],filename[side][loop]); if (rtGetString (tmpstr, MAX_PATH_LEN, "Enter Clone Name", NULL,RT_Window,W, TAG_END)) { if (stricmp(pathstr,tmpstr)!=0) { errnum=DirFunc(pathstr,tmpstr,G_Copy); if (errnum) DosError("Error Cloning Directory",pathstr,errnum); ReadDir=DF_READOTHER; } } break; case G_Swap: UpdateStat("Swap",cpath[side],cpath[otherside],filename[side][loop]); errnum=DirFunc(pathstr,tmpstr,mode); if (errnum) DosError("Error Swaping Directory",pathstr,errnum); ReadDir=DF_READBOTH; break; } } if (errnum==1) cancel=TRUE; } loop++; if (loop==totalfiles[side]) done=TRUE; } while (!cancel && !done); } switch(mode) { case G_Archive: if (arcfile) /* if file is open */ { fclose(arcfile); /* close it */ if (!cancel) /* did user cancel function ? */ { /* nope */ ReadDir+=DF_READOTHER; UpdateStat("Archiving File Using File List",cpath[side],"",""); cdto(cpath[side]); strcpy(tmpstr,CommandString[C_Archive]); strfcat(tmpstr," A -r \"",MAX_PATH_LEN); strfcat(tmpstr,arcname,MAX_PATH_LEN); strfcat(tmpstr,"\" @T:AFCopy.TMP",MAX_PATH_LEN); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) /*cancel=*/DosError("Error Running Archiver",tmpstr,errnum); /* cancel not needed again! */ } filenuke("T:AFCopy.TMP"); /* delete it */ } break; } if (Errors) { rtEZRequest ("There Were Errors!",okmsg,NULL,(struct TagItem *)&reqtags,NULL); } CloseWindow(statw); statw=NULL; } FreeGadgets(statglist); } } if (ReadDir) { if (ReadDir==DF_READBOTH || ReadDir==DF_READCURRENT) { lognewdir(side,cpath[side]); } if (ReadDir==DF_READBOTH || ReadDir==DF_READOTHER) { lognewdir(otherside,cpath[otherside]); } } if (tempautooverwrite) autooverwrite=FALSE; /* tempauto.. can only become true if autooverwrite is off in the first place. */ } FreeNameList(ErrorList); FreeMem(ErrorList,sizeof (struct List)); } } void DosFunction( void ) { long asynch=FALSE; if (asynch=rtGetString (dosstr, MAX_COMMAND_LEN, "Enter Dos Command", NULL, RTGS_GadFmt, "Run|Run Asynch|Cancel", RT_Window,W, TAG_END)) { ExecCommand(dosstr,asynch==2 ? TRUE : FALSE,shufflescreens); } } void pickscreen( void ) { struct rtScreenModeRequester *scrmodereq; if (scrmodereq = rtAllocRequestA (RT_SCREENMODEREQ, NULL)) { if (rtScreenModeRequest (scrmodereq, "Select A Screen mode:",RTSC_Flags,SCREQF_GUIMODES,RT_Window,W,TAG_END)) { useworkbenchscreen=FALSE; scrID=scrmodereq->DisplayID; scrH=scrmodereq->DisplayHeight < 256 ? 256 : scrmodereq->DisplayHeight; } else { scrID=-1; useworkbenchscreen=TRUE; } } } void closeafcopywindow( void ) { if (MainMenu) { ClearMenuStrip(W); FreeMenus(MainMenu); MainMenu=NULL; } if (W) { myproc->pr_WindowPtr = oldwinptr; CloseWindow(W); W=NULL; } if (glist) { FreeGadgets(glist); glist=NULL; } if (vi) { FreeVisualInfo(vi); vi=NULL; } if (mysc) { if (customscreenopen) { CloseScreen(mysc); // when i put this in a for next loop it crashes! customscreenopen=FALSE; } else { UnlockPubScreen(NULL, mysc); } mysc=NULL; } } void openthescreen( void) { BOOL ok=FALSE; do { if (useworkbenchscreen) { if (mysc = LockPubScreen(NULL)) ok=TRUE; } else { if (mysc = OpenScreenTags( NULL, SA_Left, 16, SA_Top, 0, SA_Width, 640, SA_Height, scrH, SA_Depth, 3, SA_Colors, &ScreenColors[0], SA_Font, &ScreenFontAttr, SA_Type, CUSTOMSCREEN, SA_DisplayID, scrID, SA_AutoScroll, TRUE, SA_Overscan, OSCAN_TEXT, SA_Pens, &DriPens[0], SA_Title, screentitle, SA_PubName,"AFCOPY", TAG_DONE )) { PubScreenStatus(mysc,0); customscreenopen=TRUE; ok=TRUE; } } if (!ok) { errormsg("Error Opening Screen, Please Select\n" "a different screenmode or cancel the\n" "screenmode requester to open on the\n" "default public screen!"); pickscreen(); } } while (!ok); } BOOL openafcopywindow( void ) { BOOL retval=FALSE,done=FALSE; glist=NULL; W=NULL; mysc=NULL; vi=NULL; MainMenu=NULL; customscreenopen=FALSE; openthescreen(); // Set Up Visual Info if (mysc) { if (mysc->Height<=256) { wtop=0; } else { if (customscreenopen) { wtop=11; } else { wtop=(mysc->Height-(lines_per_side*FILEHEIGHT+95)) / 2; } } if (vi = GetVisualInfo(mysc, TAG_DONE)) { topborder = mysc->WBorTop + (mysc->Font->ta_YSize + 1); zoomcoords[3]=topborder; /* set height of iconified window to that of the topborder */ do { if (W=OpenWindowTags(NULL, WA_Left,(mysc->Width-640) / 2, WA_Top,wtop, WA_Width,640, WA_MinWidth,640, WA_MinHeight,lines_per_side*FILEHEIGHT+96, WA_InnerHeight,lines_per_side*FILEHEIGHT+84, WA_AutoAdjust, FALSE, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_CloseGadget, TRUE, WA_SmartRefresh, TRUE, WA_Zoom, zoomcoords, WA_NewLookMenus, TRUE, WA_ReportMouse, TRUE, WA_IDCMP, IDCMP_REFRESHWINDOW| IDCMP_MENUPICK| BUTTONIDCMP| IDCMP_MOUSEBUTTONS| IDCMP_CLOSEWINDOW| ARROWIDCMP| SCROLLERIDCMP| IDCMP_VANILLAKEY| IDCMP_RAWKEY| IDCMP_DISKINSERTED| IDCMP_ACTIVEWINDOW| IDCMP_MOUSEMOVE| IDCMP_NEWSIZE, WA_Title,windowtitle, WA_PubScreen, mysc, WA_ScreenTitle,screentitle, TAG_END)) { myproc->pr_WindowPtr=W; done=TRUE; } else { lines_per_side--; if (lines_per_sideRPort,ScreenFont); /* set the font for the file names */ retval=TRUE; RefreshGadgets(glist,W,NULL); } else MainMenu=NULL; } } else W=NULL; } else vi=NULL; } return(retval); } void resetslider(int side) { GT_SetGadgetAttrs(my_gads[G_Sliderleft+side], W, NULL, GTSC_Top, displayoffset[side], GTSC_Total, totalfiles[side], GTSC_Visible, totalfiles[side] < lines_per_side ? totalfiles[side] : lines_per_side, TAG_END); } void UpdateMainWindow( void ) { Updatedisplay(0); resetslider(0); Updatedisplay(1); resetslider(1); ActiveSide(currentside); } /**************************************************************************************** Event Handler! ****************************************************************************************/ void handleevent(UWORD what,UWORD code) /* shove a GadgetID in WHAT */ /* if applicable slidergadget's code goes in CODE */ { switch(what) { case G_SortLeft: sortmode[0]++; if (sortmode[0]>SORT_MAX) sortmode[0]=SORT_MIN; qsortfiles(0,0,totalfiles[0]-1); displayfilelist(0,displayoffset[0]); break; case G_SortRight: sortmode[1]++; if (sortmode[1]>SORT_MAX) sortmode[1]=SORT_MIN; qsortfiles(1,0,totalfiles[1]-1); displayfilelist(1,displayoffset[1]); break; case G_Deviceleft0: case G_Deviceleft1: case G_Deviceleft2: case G_Deviceleft3: case G_Deviceleft4: case G_Deviceleft5: case G_Deviceleft6: case G_Deviceleft7: case G_Deviceleft8: case G_Deviceleft9: case G_Deviceleft10: case G_Deviceleft11: currentside=0; lognewdir(0,devicegadactual[0][what-G_Deviceleft0]); break; case G_Deviceright0: case G_Deviceright1: case G_Deviceright2: case G_Deviceright3: case G_Deviceright4: case G_Deviceright5: case G_Deviceright6: case G_Deviceright7: case G_Deviceright8: case G_Deviceright9: case G_Deviceright10: case G_Deviceright11: currentside=1; lognewdir(1,devicegadactual[1][what-G_Deviceright0]); break; case G_Regetleft: case G_Pathleft: currentside=0; lognewdir(0,((struct StringInfo *)my_gads[G_Pathleft]->SpecialInfo)->Buffer); break; case G_Regetright: case G_Pathright: currentside=1; lognewdir(1,((struct StringInfo *)my_gads[G_Pathright]->SpecialInfo)->Buffer); break; case G_Parentleft: currentside=0; if (pathok[0]) doparent(0); break; case G_Parentright: currentside=1; if (pathok[1]) doparent(1); break; case G_Makedir: Makedir(currentside); break; case G_Mark: setmarks(currentside,MARK); displayfilelist(currentside,displayoffset[currentside]); break; case G_Unmark: setmarks(currentside,UNMARK); displayfilelist(currentside,displayoffset[currentside]); break; case G_Reverse: setmarks(currentside,REVERSE); displayfilelist(currentside,displayoffset[currentside]); break; case G_Rename: case G_Copy: case G_Clone: case G_Swap: case G_Delete: case G_View: case G_Read: case G_Edit: case G_Hear: case G_Info: case G_Execute: case G_Run: case G_Comment: case G_Archive: case G_Unarc: case G_Batch: case G_Protect: case G_Userleft0: case G_Userleft1: case G_Userleft2: case G_Userleft3: case G_Userleft4: case G_Userleft5: case G_Userleft6: case G_Userleft7: case G_Userleft8: case G_Userleft9: case G_Userleft10: case G_Userleft11: case G_Userleft12: case G_Userleft13: case G_Userleft14: case G_Userright0: case G_Userright1: case G_Userright2: case G_Userright3: case G_Userright4: case G_Userright5: case G_Userright6: case G_Userright7: case G_Userright8: case G_Userright9: case G_Userright10: case G_Userright11: case G_Userright12: case G_Userright13: case G_Userright14: Dofunction(what,currentside); break; case G_Dos: DosFunction(); break; case G_Volumes: findvolumes(currentside); break; case G_Sliderleft: currentside=0; displayoffset[0]=code; displayfilelist(0,displayoffset[0]); break; case G_Sliderright: currentside=1; displayoffset[1]=code; displayfilelist(1,displayoffset[1]); } } void handlekey(UWORD key) { int id=-1; switch (key) { case 'a': case 'A': id=G_Read; break; case 'b': case 'B': id=G_Batch; break; case 'c': case 'C': id=G_Copy; break; case 'd': case 'D': id=G_Delete; break; case 'e': case 'E': id=G_Edit; break; /* f-g */ case 'h': case 'H': id=G_Hear; break; case 'i': case 'I': id=G_Info; break; /* j-k */ case 'l': case 'L': id=G_Volumes; break; case 'm': case 'M': id=G_Makedir; break; /* n */ case 'o': case 'O': id=G_Clone; break; case 'p': case 'P': id=G_Protect; break; /* q */ case 'r': case 'R': id=G_Rename; break; case 's': case 'S': id=G_Swap; break; case 't': case 'T': id=G_Comment; break; case 'u': case 'U': id=G_Unarc; break; case 'v': case 'V': id=G_View; break; /* w */ case 'x': case 'X': id=G_Execute; break; /* y */ case 'z': case 'Z': id=G_Archive; break; /* Z is for ZIP !! */ case '#': id=G_Run; break; case '+': id=G_Mark; break; case '-': id=G_Unmark; break; case '*': id=G_Reverse; break; case '/': id=G_Parentleft+currentside; break; case '.': id=G_Regetleft+currentside; break; } if (id!=-1) handleevent(id,0); } void checkfileselect(int Code,int MouseX,int MouseY,LONG action,BOOL CheckDoubleClick) { int side,oldside=currentside,fileid,lineid; ULONG sec,mic; char newpath[MAX_PATH_LEN+1]; if (active) { for (side=0;side<=1;side++) { if (inrect(MouseX,MouseY, filexpos[side], topborder+FILEYPOS, filexpos[side]+FILEWIDTH, topborder+FILEYPOS+(FILEHEIGHT*lines_per_side))) { if ((oldside==side && (Code==SELECTDOWN)) || (Code==MENUNULL)) { currentside=side; lineid=((MouseY-topborder-FILEYPOS) / FILEHEIGHT); if (lineid>=0 && lineid0) { last_x=0; last_y=0; strcpy(newpath,((struct StringInfo *)my_gads[G_Pathleft+currentside]->SpecialInfo)->Buffer); if (AddPart(newpath,filename[currentside][fileid],MAX_PATH_LEN)) { lognewdir(currentside,newpath); } } break; } } } } else { if (Code==SELECTDOWN) currentside=side; } } } } } #define T_TAG TRUE #define T_UNTAG FALSE void modtags(int side,int tmode,char *patt) { int loop; char match[83]; if (pathok[side]) { ParsePatternNoCase(patt,match,82); for (loop=0;loopRPort,x1,y1); Draw(W->RPort,x1,y2); Draw(W->RPort,x2,y2); Draw(W->RPort,x2,y1); Draw(W->RPort,x1,y1); } void ActiveSide(int side) { DrawBevelBox(W->RPort, filexpos[side]-1, topborder+FILEYPOS-1, FILEWIDTH+3, (FILEHEIGHT*lines_per_side)+2, GT_VisualInfo,vi,TAG_DONE); DrawBevelBox(W->RPort, filexpos[1-side]-1, topborder+FILEYPOS-1, FILEWIDTH+3, (FILEHEIGHT*lines_per_side)+2, GT_VisualInfo,vi,GTBB_Recessed,TRUE,TAG_DONE); /* SetAPen(W->RPort,2); SetBPen(W->RPort,0); Rectangle(W,filexpos[side]-1, topborder+FILEYPOS-1, filexpos[side]+FILEWIDTH+1,topborder+FILEYPOS+(FILEHEIGHT*lines_per_side)-1); SetAPen(W->RPort,1); Rectangle(W,filexpos[1-side]-1, topborder+FILEYPOS-1, filexpos[1-side]+FILEWIDTH+1,topborder+FILEYPOS+(FILEHEIGHT*lines_per_side)-1); */ } #define C_RIGHT 78 #define C_LEFT 79 void handlerawkey(UWORD key) { switch(key) { case C_RIGHT: currentside=1; break; case C_LEFT: currentside=0; break; } } void handleidcmp(void) { struct IntuiMessage *imsg,*imsgo; struct Gadget *gad; BOOL done = FALSE; char whatdisk[5]="DFx:"; if (imsg=AllocMem(sizeof(struct IntuiMessage),MEMF_PUBLIC)) { while (!done) { Wait (1 << W->UserPort->mp_SigBit); while (imsgo = GT_GetIMsg(W->UserPort)) { CopyMem(imsgo,imsg,sizeof(struct IntuiMessage)); GT_ReplyIMsg(imsgo); gad = (struct Gadget *)imsg->IAddress; switch(imsg->Class) { case IDCMP_MOUSEMOVE: if (imsg->IAddress==W) { if (mouseupdn==104) checkfileselect(mouseupdn,imsg->MouseX,imsg->MouseY,mouseaction,FALSE); break; } else { mouseaction=SELECTTOGGLE; } case IDCMP_GADGETDOWN: case IDCMP_GADGETUP: handleevent(gad->GadgetID,imsg->Code); break; case IDCMP_VANILLAKEY: handlekey(imsg->Code); break; case IDCMP_RAWKEY: handlerawkey(imsg->Code); break; case IDCMP_MENUPICK: if (handlemenu(MENUNUM(imsg->Code),ITEMNUM(imsg->Code))) { done = TRUE; break; } case IDCMP_MOUSEBUTTONS: mouseupdn=imsg->Code; checkfileselect(imsg->Code,imsg->MouseX,imsg->MouseY,SELECTTOGGLE,TRUE); break; case IDCMP_CLOSEWINDOW: done = TRUE; break; case IDCMP_INACTIVEWINDOW: active=FALSE; break; case IDCMP_ACTIVEWINDOW: active=TRUE; break; case IDCMP_NEWSIZE: iconised=!iconised; if (!iconised) { UpdateMainWindow(); } /* do something here, or shall we ? no, i dont think we will. Oh well */ break; case IDCMP_DISKINSERTED: if (!ignoreinserteddisks && !iconised) { whatdisk[2]='0'+imsg->Code; switch (rtEZRequest("Disk Inserted! Log it ?","_Left|_Right|_CANCEL",NULL,(struct TagItem *)&reqtags,NULL)) { case 1: lognewdir(0,whatdisk); break; case 2: lognewdir(1,whatdisk); break; } } break; } if (!done) ActiveSide(currentside); } } FreeMem(imsg,sizeof (struct IntuiMessage)); } } int GetFont( void ) { if ((ScreenFontAttr.ta_Flags & FPB_DISKFONT) != FPB_DISKFONT) { ScreenFont=OpenDiskFont(&ScreenFontAttr); } else { ScreenFont=OpenFont(&ScreenFontAttr); } if (ScreenFont) { return(TRUE); } else { rtEZRequest ("Could Open Font","Hmm, Very strange!",NULL,(struct TagItem *)&reqtags,NULL); return(FALSE); } } void PickFont( void ) { struct rtFontRequester *fontreq; if (fontreq = rtAllocRequestA (RT_FONTREQ, NULL)) { fontreq->Flags = FREQF_FIXEDWIDTH; if (rtFontRequest (fontreq, "Pick a font",RTFO_MinHeight,8,RTFO_MaxHeight,8,TAG_END)) { strcpy(ScreenFontAttr.ta_Name,fontreq->Attr.ta_Name); ScreenFontAttr.ta_YSize=fontreq->Attr.ta_YSize; ScreenFontAttr.ta_Style=fontreq->Attr.ta_Style; ScreenFontAttr.ta_Flags=fontreq->Attr.ta_Flags; } rtFreeRequest (fontreq); } else { rtEZRequest ("Out of memory!", "Bogus!", NULL, NULL); } } void freeallocated(int side ) { int loop; for (loop=0;loopsm_NumArgs>1) { WBarg=WBmsg->sm_ArgList; WBarg++; if (WBarg->wa_Name && WBarg->wa_Lock) { if (NameFromLock(WBarg->wa_Lock,configname,MAX_PATH_LEN)) { if (!AddPart(configname,WBarg->wa_Name,MAX_PATH_LEN)) { strcpy(configname,DEFAULTCONFIGNAME); } } } } } else { if (argc==2) strcpy(configname,argv[1]); } WB2CLI((struct WBStartup *)argv,4000,DOSBase); /* so you get the default path! */ myproc = (struct Process *)FindTask (NULL); if (!( (ReqToolsBase = (struct ReqToolsBase *) OpenLibrary (REQTOOLSNAME, REQTOOLSVERSION)) || (ReqToolsBase = (struct ReqToolsBase *) OpenLibrary ("DH0:Libs/"REQTOOLSNAME, REQTOOLSVERSION)) ) ) { puts("You need \"reqtools.library\" V38 or higher to run AFCopy!\n" "You should find it in the AFCopy Archive! and it needs to be in LIBS:\n" "Install file and try program again"); } else { if ((GadToolsBase = OpenLibrary("gadtools.library", 37)) == NULL ) { rtEZRequest ("Could Not Open\n\"gadtools.library\" V37+","Eeek!",NULL,(struct TagItem *)&reqtags,NULL); } else { oldwinptr = myproc->pr_WindowPtr; blankusergads(); setdefaultconfig(); if (!LoadConfig(configname)) { if (rtEZRequest("Config Not Loaded!\nSave defaults ?","Yep, save them|dont even think about it!",NULL,NULL)) { SaveConfig(DEFAULTCONFIGNAME); } } if (GetFont()) { sprintf(screentitle,"AFCopy" #ifdef CPU030 " '030" #endif " %d.%d (C) 1993-4 Hydra!/Tension",VERSION,REVISION); sprintf(windowtitle,"AFCOPY V%d.%d",VERSION,REVISION); SetProgramName(windowtitle); if (openafcopywindow()) { lognewdir(0,cpath[0]); lognewdir(1,cpath[1]); handleidcmp(); /* start looking for input.. */ } if (W) closeafcopywindow(); CloseFont(ScreenFont); } CloseLibrary(GadToolsBase); /* close libs */ } CloseLibrary ((struct Library *)ReqToolsBase); } if (outputconfile) Close(outputconfile); freeallocated(0); freeallocated(1); }