home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ________ _______ _______ _______ _______ __ __ / ____ /\ / _____/\ / _____/\ / ___ /\ / ___ /\ / /\ / /\ / /\__/ / // /\____\// /\____\// /\_/ / // /\_/ / // / / / / / / /_/_/ / // /_/_ / / / / / // / // /_// / // /_/_/ / / / ____ / // ____/\ / / / / / // / // _____/ //_____ / / / /\__/ / // /\___\/ / / / / / // / // /\____\/ \____/ / / / / / / / // / / / /_/__ / /_// / // / / ______/ / / /_/ / / / //_/ / /______/\ /______/ //_/ / /_______/ / \_\/ \_\/ \_\/ \______\/ \______\/ \_\/ \_______\/ HYDRA - Tension/LSD AFCopy V4 is (C) 1993-5 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!! 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 38) delete files from list to avoid re-reading file list.. */ /* Not TOO many include files... (honest!!) */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <time.h> #include <exec/types.h> #include <exec/memory.h> #include <exec/execbase.h> #include <exec/nodes.h> #include <exec/lists.h> #include <dos/dos.h> #include <dos/dostags.h> #include <dos/filehandler.h> #include <libraries/dos.h> #include <intuition/intuition.h> #include <intuition/gadgetclass.h> #include <libraries/reqtools.h> #include <libraries/dos.h> #include <wb2cli.h> /* for the correct PATH settings when run from WB */ #include <clib/exec_protos.h> #include <clib/dos_protos.h> #include <clib/intuition_protos.h> #include <clib/gadtools_protos.h> #include <clib/graphics_protos.h> #include <clib/diskfont_protos.h> #include <clib/reqtools_protos.h> #include <clib/wb_protos.h> #include <clib/alib_protos.h> /* 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); } void checkcustomscreenwindows( void ) { if (customscreenopen) { while (mysc->FirstWindow && mysc->FirstWindow->NextWindow) { errormsg("Please Close All Windows!"); }; } } /* * 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+pos<destlen && source[pos]) { dest[where+pos]=source[pos]; pos++; } dest[where+pos]='\0'; } // small routine to test wether the end of a string equals the match string // usefull for checking filename extensions BOOL endofstring(char *whole,char *match) { short l1,l2; for (l1=strlen(whole)-1,l2=strlen(match)-1; whole[l1]==match[l2] && l1>0 && 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(short 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(short side,char *fname,LONG size,LONG type,BYTE tags) { if (totalfiles[side]<MAX_FILES_IN_LIST && stricmp(fname,"") && size>=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. */ void displaysinglefile(short side,int ypos,int start) { struct tm *TM; time_t t; if (filetags[side][start]) { SetBPen(W->RPort,highlightcol); } else { SetBPen(W->RPort,NORMALCOL); } /* SET FOREGROUND COLOUR */ if (filetype[side][start]>0) { strcpy(dummystring,"<DIR>"); SetAPen(W->RPort,dircol); } else { stci_d(dummystring,filesize[side][start]); SetAPen(W->RPort,filecol); } /* use below when/if attrs are used.... switch(DisplayType[side]) { case D_SIZE: break; case D_DATES: t=__datecvt(filedate[side][start]); TM=localtime(t); strftime(dummystring, 9,"%d/%m/%y", TM); break; case D_ATTRIB: break; } until then use the IF below. */ if (DisplayType[side]==D_DATES) { t=__datecvt(&filedate[side][start]); TM=localtime(&t); strftime(dummystring, 9,"%d/%m/%y", TM); } strncpy(outputstring,filename[side][start],32); strpad(outputstring,32); outputstring[31-strlen(dummystring)]=0; strcat(outputstring," "); strcat(outputstring,dummystring); /* OUTPUT TEXT */ Move(W->RPort,filexpos[side]+2,topborder+FILEYPOS+FONTBASELINE+(FILEHEIGHT*ypos)); Text(W->RPort,outputstring,strlen(outputstring)); } /* this routine clears the are of the screen where a filename would have been * */ void wipefile(short side,int ypos) { SetAPen(W->RPort,0); SetBPen(W->RPort,0); RectFill(W->RPort,filexpos[side]+1,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(short side,int start) { int loop=0; while (loop<lines_per_side) { if (start+loop <totalfiles[side]) displaysinglefile(side,loop,start+loop); else wipefile(side,loop); loop++; } } /* updates the name in the path gadget with the string in cpath[] * */ void updatepath(short side) { GT_SetGadgetAttrs(my_gads[G_Pathleft+side], W, NULL, GTST_String, cpath[side], TAG_END); } /* read a new directory. * */ void lognewdir(short side, char *path) { if (path[0]!='\0') { addterm(path); strncpy(cpath[side],path,MAX_PATH_LEN); getfiles(side,cpath[side]); updatepath(side); displayoffset[side]=0; displayfilelist(side,displayoffset[side]); } else { Updatedisplay(side); } } /* change to the parent directory of the current one. * */ void doparent(short side) { char newpath[MAX_PATH_LEN+1]; strcpy(newpath,cpath[side]); getparent(newpath); /* is it already in root ? */ if (stricmp(newpath,cpath[side])) { lognewdir(side,newpath); } else { findvolumes(currentside); } } void updateselected(short side) { sprintf(dummystring,"%3d/%-3d %7d",selectedfiles[side],totalfiles[side],(int)(selectedsize[side] / 1024)); SetAPen(W->RPort,2); SetBPen(W->RPort,0); OutTextXY(W,filexpos[side]+2+(side*17),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(short side,int action) { int loop; if (action!=REVERSE) { selectedfiles[side]=0; selectedsize[side]=0; } for (loop=0;loop<totalfiles[side];loop++) { switch (action) { case MARK: filetags[side][loop]=TRUE; selectedfiles[side]++; selectedsize[side]+=filesize[side][loop]; break; case UNMARK: filetags[side][loop]=FALSE; break; case REVERSE: if (filetags[side][loop]) { selected(side,loop,FALSE); } else { selected(side,loop,TRUE); } break; } } updateselected(side); } /* Display some info * */ void About(void) { char outstr[500]; sprintf(outstr,"AFCOPY V%d.%d (C) 1995 Hydra/Tension/LSD\n\n" "Written And Designed By Hydra/Tension/LSD\n" "Beta Tested By Blue Aardvark/TSN And Big W/TSN" ,VERSION,REVISION); rtEZRequestTags(outstr,"I Like it!",NULL,NULL, RTGS_Flags, GSREQF_CENTERTEXT, RT_Window,W,TAG_END); rtEZRequestTags("If you find any bugs or errors in AFCopy\n" "then >Please< 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(int amountleft,int amounttotal,char *functionstr,char *fromstr,char *tostr,char *fname) { char outstr[74]; if (amounttotal!=0) { sprintf(outstr,"Function: %s Selected: %d Done: %d Complete: %3.0f%%",functionstr,amounttotal,amounttotal-amountleft,((float)(amounttotal-amountleft)/(float)amounttotal)*100); strpad(outstr,73); outstr[72]='\0'; OutTextXY(statw,8,topborder+15+FONTBASELINE,outstr); } 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(short side) { updatepath(side); qsortfiles(side,0,totalfiles[side]-1); updateslider(side,displayoffset[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(short side) { int loop; int retval=0; for (loop=0;loop<totalfiles[side];loop++) { if (filetags[side][loop]) retval++; } return(retval); } /*************** main functions every gadget that has anything to do with files comes through here... (including user gadgets with flags set to UG_SENDFILES) ***************/ #define DF_READNONE 0 #define DF_READCURRENT 1 #define DF_READOTHER 2 /* defines for reading dir after function */ #define DF_READBOTH 3 void handlerefresh(void) { struct IntuiMessage *imsg; ULONG imsgClass; UWORD imsgCode; struct Gadget *gad; while (imsg = GT_GetIMsg(W->UserPort)) { 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 CopyFileDetails(int from,int to,int which) { if (totalfiles[to]<MAX_FILES_IN_LIST) { if (allocmemforname(to)) { strcpy(filename[to][totalfiles[to]],filename[from][which]); filetype[to][totalfiles[to]]=filetype[from][which]; filesize[to][totalfiles[to]]=filesize[from][which]; filedate[to][totalfiles[to]]=filedate[from][which]; filetags[to][totalfiles[to]]=0; totalfiles[to]++; selected(to,totalfiles[to]-1,TRUE); } } } void Dofunction(int mode,short side) { int errnum=0,loop=0,myprot=-1,where; BOOL doall=FALSE,ok=FALSE,done=FALSE,cancel=FALSE,ignorebatcherrors; int ReadDir=DF_READNONE; short otherside=1-side; char arcname[MAX_PATH_LEN+1],pathstr[MAX_PATH_LEN+1],tmpstr[MAX_PATH_LEN+1]; FILE *arcfile=NULL; BPTR FL; int amountleft; int last_displayoffset=0; tempautooverwrite=FALSE; Errors=0; if (ErrorList=(struct List *)AllocMem(sizeof(struct List),MEMF_ANY)) { NewList(ErrorList); if (selectedfiles[side]>0) { amountleft=selectedfiles[side]; 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 ?","_Yes|_No!",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=(nomessages) || (rtEZRequest("Ignore Errors Between Programs ?","_Yes|_No!",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]) { displayfilelist(side,0); do { handlerefresh(); if (filetags[side][loop] && !(cancel=CheckStatCancel()) ) { // new for v4.2 if (loop>=last_displayoffset+lines_per_side) { last_displayoffset=loop; if (last_displayoffset>totalfiles[side]-lines_per_side) last_displayoffset=totalfiles[side]-lines_per_side; displayfilelist(side,last_displayoffset); updateslider(side,last_displayoffset); } // end new bit.. actuallytransferred=AT_NO; 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(amountleft,selectedfiles[side],"Protect",cpath[side],"",filename[side][loop]); errnum=SetProtection(pathstr,myprot); if (!errnum) DosError("Error Protecting File",pathstr,errnum); break; case G_View: UpdateStat(amountleft,selectedfiles[side],"View",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_View],side,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Viewing File",pathstr,errnum); break; case G_Read: UpdateStat(amountleft,selectedfiles[side],"Read",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Read],side,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Reading File",pathstr,errnum); break; case G_Edit: UpdateStat(amountleft,selectedfiles[side],"Edit",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Edit],side,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Editing File",pathstr,errnum); break; case G_Hear: UpdateStat(amountleft,selectedfiles[side],"Hear",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Hear],side,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(amountleft,selectedfiles[side],"Execute Script",cpath[side],"",filename[side][loop]); createstring(tmpstr,CommandString[C_Execute],side,loop,CS_ALL); errnum=ExecCommand(tmpstr,FALSE,shufflescreens); if (errnum && !nomessages) DosError("Error Executing Script",pathstr,errnum); break; case G_Run: UpdateStat(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"Archive 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(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"Command Batch",cpath[side],"",filename[side][loop]); createstring(tmpstr,batchstring,side,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(amountleft,selectedfiles[side],"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,loop,CS_ALL); } else { createstring(tmpstr,tmpstr,side,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(amountleft,selectedfiles[side],"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,loop,CS_ALL); } else { createstring(tmpstr,tmpstr,side,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(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"Delete",cpath[side],"",filename[side][loop]); errnum=filenuke(pathstr); if (errnum>0) DosError("Error Deleting File",pathstr,errnum); else { ReadDir=DF_READCURRENT; } break; case G_Copy: UpdateStat(amountleft,selectedfiles[side],"Copy",cpath[side],cpath[otherside],filename[side][loop]); errnum=filecopy(pathstr,tmpstr); if (errnum>0) DosError("Error Copying File",pathstr,errnum); if (actuallytransferred==AT_YES) { CopyFileDetails(side,otherside,loop); } if (actuallytransferred==AT_OVERW) { ReadDir=DF_READOTHER; } break; case G_Clone: UpdateStat(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"Swap",cpath[side],cpath[otherside],filename[side][loop]); errnum=fileswap(pathstr,tmpstr); if (errnum>0) DosError("Error Swapping File",pathstr,errnum); if (ReadDir!=DF_READBOTH) ReadDir=DF_READCURRENT; if (actuallytransferred==AT_YES) { CopyFileDetails(side,otherside,loop); } if (actuallytransferred==AT_OVERW) { ReadDir=DF_READBOTH; } break; } } else { /* DIR */ switch(mode) { case G_Delete: UpdateStat(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"Copy",cpath[side],cpath[otherside],filename[side][loop]); errnum=DirFunc(pathstr,tmpstr,mode); ReadDir=DF_READOTHER; if (errnum) DosError("Error Copying Directory",pathstr,errnum); break; case G_Clone: UpdateStat(amountleft,selectedfiles[side],"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(amountleft,selectedfiles[side],"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; amountleft--; } 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(amountleft,selectedfiles[side],"Archiving",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]); } } switch (mode) { case G_Copy: case G_Clone: case G_Swap: Updatedisplay(otherside); break; } } FreeNameList(ErrorList); FreeMem(ErrorList,sizeof (struct List)); } updateslider(side,displayoffset[side]); displayfilelist(side,displayoffset[side]); if (tempautooverwrite) autooverwrite=FALSE; /* tempauto.. can only become true if autooverwrite is off in the first place. */ } 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; short tries; do { if (useworkbenchscreen) { if (mysc = LockPubScreen(NULL)) ok=TRUE; } else { tries=0; do { strcpy(screenname,"AFCOPY"); if (tries!=0) { sprintf(dummystring,"%d",tries); strcat(screenname,dummystring); } 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,screenname, TAG_DONE )) { PubScreenStatus(mysc,0); customscreenopen=TRUE; ok=TRUE; } else { tries++; } } while (tries<50 && !ok); } 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_side<MIN_LINES_PER_SIDE) { done=TRUE; } } } while (!done); if (W) { if (createAllGadgets(&glist, vi, topborder,my_gads)) { AddGList(W,glist,0,-1,NULL); // wonder if this'll work first time ? if (MainMenu = CreateMenus( MainNewMenu, GTMN_NewLookMenus,TRUE,TAG_DONE)) { LayoutMenus(MainMenu,vi,GTMN_TextAttr, &ScreenFontAttr,GTMN_NewLookMenus,TRUE,TAG_DONE); SetMenuStrip(W,MainMenu); GT_RefreshWindow(W, NULL); /* just to make sure */ SetFont(W->RPort,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(short 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 ) { GT_RefreshWindow(W,NULL); 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_DisplayLeft: DisplayType[0]++; if (DisplayType[0]>DISPLAY_MAX) DisplayType[0]=DISPLAY_MIN; displayfilelist(0,displayoffset[0]); break; case G_DisplayRight: DisplayType[1]++; if (DisplayType[1]>DISPLAY_MAX) DisplayType[1]=DISPLAY_MIN; 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) { short 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))) { ActiveSide(currentside); if ((oldside==side && (Code==SELECTDOWN)) || (Code==MENUNULL)) { currentside=side; lineid=((MouseY-topborder-FILEYPOS) / FILEHEIGHT); if (lineid>=0 && lineid<lines_per_side) { fileid=lineid+displayoffset[currentside]; if (fileid < totalfiles[currentside]) { switch (Code) { case SELECTDOWN : switch(action) { case SELECTTOGGLE: if (filetags[currentside][fileid]) { selected(currentside,fileid,FALSE); mouseaction=SELECTUNSET; } else { selected(currentside,fileid,TRUE); mouseaction=SELECTSET; } /* filetags[currentside][fileid]=!filetags[currentside][fileid]; if (filetags[currentside][fileid]) { mouseaction=SELECTSET; } else { mouseaction=SELECTUNSET; } */ break; case SELECTSET: if (!filetags[currentside][fileid]) { selected(currentside,fileid,TRUE); } break; case SELECTUNSET: if (filetags[currentside][fileid]) { selected(currentside,fileid,FALSE); } break; } displaysinglefile(currentside,lineid,fileid); CurrentTime(&sec,&mic); if (! (DoubleClick(last_sec,last_mic,sec,mic) && (MouseX==last_x && MouseY==last_y && CheckDoubleClick))) { last_x=MouseX; last_y=MouseY; last_sec=sec; last_mic=mic; break; } case MENUNULL : if (filetype[currentside][fileid]>0) { last_x=0; last_y=0; strcpy(newpath,cpath[currentside]); //((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 Rectangle(struct Window *W,UWORD x1,UWORD y1,UWORD x2,UWORD y2) { Move(W->RPort,x1,y1); Draw(W->RPort,x1,y2); Draw(W->RPort,x2,y2); Draw(W->RPort,x2,y1); Draw(W->RPort,x1,y1); } void ActiveSide(short 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); } void modtags(short side,int tmode,char *patt) { int loop; char match[83]; if (pathok[side]) { ParsePatternNoCase(patt,match,82); for (loop=0;loop<totalfiles[side];loop++) { if (MatchPatternNoCase(match,filename[side][loop])) { selected(side,loop,tmode); } } displayfilelist(side,displayoffset[side]); } } void GroupTag(short side,int tmode) { if (rtGetString (patt, 40, "Enter Pattern To Match Files", NULL,RT_Window,W, TAG_END)) { modtags(side,tmode,patt); } } int handlemenu(int num,int item) { char cfgname[MAX_PATH_LEN+1]; int quit=FALSE; switch(num) { case 0: switch(item) { case 0: About(); break; case 1: rtEZRequest("To change directory use the RIGHT mouse button.\n" "bet it took you ages to figure that one out!!", "It sure did!",NULL,(struct TagItem *)&reqtags,NULL); rtEZRequest("For more help look at the instructions section\n" "in AFCopy.Guide!", "Oh, Okay then.",NULL,(struct TagItem *)&reqtags,NULL); break; case 2: checkcustomscreenwindows(); quit=TRUE; break; } break; case 1: strcpy(cfgname,DEFAULTCONFIGNAME); switch(item) { case 0: quit=!EditConfig(); break; case 1: /* file selector need to go here!!! */ if (rtGetString (cfgname, MAX_PATH_LEN, "Enter Config File Name To Load", NULL,RT_Window,W, TAG_END)) { if (cfgname[0]!='\0') LoadConfig(cfgname); checkcustomscreenwindows(); closeafcopywindow(); if (!(quit=!openafcopywindow())) { UpdateMainWindow(); } } break; case 2: SaveConfig(DEFAULTCONFIGNAME); break; case 3: /* file selector need to go here!!! */ if (rtGetString (cfgname, MAX_PATH_LEN, "Enter Config File Name To Save As", NULL,RT_Window,W, TAG_END)) { if (cfgname[0]!='\0') SaveConfig(cfgname); } break; } break; case 2: /* Misc Menu */ switch(item) { case 0: GroupTag(currentside,T_TAG); break; case 1: GroupTag(currentside,T_UNTAG); break; case 2: DoFormat(); break; } break; } return(quit); } #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 (1L << 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); ActiveSide(currentside); break; case IDCMP_VANILLAKEY: handlekey(imsg->Code); ActiveSide(currentside); break; case IDCMP_RAWKEY: handlerawkey(imsg->Code); ActiveSide(currentside); 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: checkcustomscreenwindows(); 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; } } } 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",okmsg,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!", okmsg, NULL, NULL); } } void freeallocated(short side ) { int loop; for (loop=0;loop<allocated[side];loop++) { FreeMem(filename[side][loop],MAX_FILE_LEN+1); } } void main(int argc,char **argv) { struct WBStartup *WBmsg; struct WBArg *WBarg; char configname[MAX_PATH_LEN+1]=DEFAULTCONFIGNAME; if (argc==0) { WBmsg=(struct WBStartup *)argv; if (WBmsg->sm_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+",okmsg,NULL,(struct TagItem *)&reqtags,NULL); } else { oldwinptr = myproc->pr_WindowPtr; blankusergads(); setdefaultconfig(); if (!LoadConfig(configname)) { if (rtEZRequest("Config Not Loaded!\nSave defaults ?","Yes|No!",NULL,NULL)) { SaveConfig(DEFAULTCONFIGNAME); } } if (GetFont()) { sprintf(screentitle,"AFCopy" #ifdef CPU020 " 68020 Version!" #endif #ifdef CPU000 " 68000 Version" #endif " %d.%d (C) 1993-5 Hydra!/Tension",VERSION,REVISION); sprintf(windowtitle,"AFCOPY V%d.%d",VERSION,REVISION); SetProgramName(windowtitle); if (openafcopywindow()) { lognewdir(0,cpath[0]); lognewdir(1,cpath[1]); ActiveSide(0); 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); }