4 #include <exec/lists.h>
5 #include <exec/memory.h>
8 #include <dos/dostags.h>
9 #include <intuition/imageclass.h>
10 #include <workbench/startup.h>
11 #include <libraries/ctrequest.h>
13 #include <clib/exec_protos.h>
14 #include <clib/dos_protos.h>
15 #include <clib/icon_protos.h>
16 #include <clib/intuition_protos.h>
17 #include <clib/gadtools_protos.h>
18 #include <clib/graphics_protos.h>
19 #include <clib/ctrequest_protos.h>
20 #include <clib/utility_protos.h>
22 #include <pragmas/exec_sysbase_pragmas.h>
23 #include <pragmas/dos_pragmas.h>
24 #include <pragmas/icon_pragmas.h>
25 #include <pragmas/intuition_pragmas.h>
26 #include <pragmas/gadtools_pragmas.h>
27 #include <pragmas/graphics_pragmas.h>
28 #include <pragmas/ctrequest_pragmas.h>
29 #include <pragmas/utility_pragmas.h>
31 __stdargs
void NewList( struct List
*list
);
33 IMPORT
struct Library
*GadToolsBase
;
34 IMPORT
struct Library
*IntuitionBase
;
35 IMPORT
struct Library
*SysBase
;
36 IMPORT
struct Library
*GfxBase
;
37 IMPORT
struct Library
*DOSBase
;
38 IMPORT
struct Library
*UtilityBase
;
40 struct Library
*IconBase
;
41 struct Library
*CTRequestBase
;
44 struct DrawInfo
*drinfo
;
46 ULONG offx
,offy
,fonty
,sizeheight
;
47 ULONG wndwidth
,wndheight
,drawerwidth
;
54 const STATIC STRPTR engLocText
[] =
56 "Warning! You cannot get back what you delete!\nOK to delete:",
61 "drawer(s) (and there contents)?",
66 "Building Filelist...",
69 "couldn't be deleted",
71 "is protected against deletion.\n\nDelete anywhy?",
79 static const STRPTR VerString
= "$VER: delete.module 1.0 "__AMIGADATE__
;
81 STATIC BOOL
CreateGadgets(void);
83 //-------------------------------------
88 STATIC VOID
SR_LenFunc(VOID
)
90 __emit(0x5293); // ADDQ.L #1,(A3)
93 STATIC VOID
SR_CopyFunc(VOID
)
95 __emit(0x16c0); // MOVE.B D0,(A3)+
98 STATIC VOID
SR_CopyFuncNoUnderscore(VOID
)
100 __emit(0xb03c); __emit(0x005f); // CMP.B #'_',D0
101 __emit(0x6702); // BEQ.B .end(RTS)
102 __emit(0x16c0); // MOVE.B D0,(A3)+
105 STATIC VOID
SR_Dummy(VOID
)
111 VOID
SR_LenFunc(VOID
);
112 VOID
SR_CopyFunc(VOID
);
113 VOID
SR_CopyFuncNoUnderscore(VOID
);
118 //-------------------------------------
119 LONG
SimpleRequestArgs( struct Window
*wnd
, struct EasyStruct
*easy
, ULONG
*idcmp
, STRPTR reqType
, STRPTR fallBackType
, APTR argList
)
121 struct EasyCTRStruct
*ctr
;
123 // if ctrrequest.library isn't available call the
124 // intuituin function instead
127 STRPTR gadgetText
= (STRPTR
)easy
->es_GadgetFormat
;
128 STRPTR newGadgetText
;
138 // Skip the text format
139 if( easy
->es_TextFormat
) nd
= RawDoFmt(easy
->es_TextFormat
,argList
,(void(*)())SR_Dummy
,NULL
);
142 // Calculate the length of the formatted GadgetText
144 RawDoFmt(easy
->es_GadgetFormat
,nd
,(void(*)())SR_LenFunc
,&len
);
146 newGadgetText
= (STRPTR
)AllocVec( len
+2, 0 );
147 if( !newGadgetText
) return EasyRequestArgs(wnd
,easy
,idcmp
,argList
);
151 struct EasyStruct es
;
153 // Format the gadgettext without underscores
154 RawDoFmt(easy
->es_GadgetFormat
,nd
,(void(*)())SR_CopyFuncNoUnderscore
,newGadgetText
);
156 es
.es_StructSize
= sizeof(struct EasyStruct
);
157 es
.es_Flags
= easy
->es_Flags
;
158 es
.es_Title
= easy
->es_Title
;
159 es
.es_TextFormat
= easy
->es_TextFormat
;
160 es
.es_GadgetFormat
= newGadgetText
;
162 val
= EasyRequestArgs(wnd
,&es
,idcmp
,argList
);
163 FreeVec( newGadgetText
);
168 // Alloc an EasyCTRStruct
169 ctr
= (struct EasyCTRStruct
*)AllocVec( sizeof(struct EasyCTRStruct
),MEMF_CLEAR
);
174 // Fill in special things
175 ctr
->ectr_Title
= easy
->es_Title
;
176 ctr
->ectr_RequesterType
= reqType
;
177 ctr
->ectr_RequesterType_FB
=fallBackType
;
178 ctr
->ectr_TimeOutmodes
= NULL
;//timeOutmodes;
179 ctr
->ectr_Screen
= wnd
?wnd
->WScreen
:NULL
;
181 // Is any additional Arg given?
184 // No - take the Body and Gadget strings like they are
185 ctr
->ectr_Body
= easy
->es_TextFormat
;
186 ctr
->ectr_Gadgets
= easy
->es_GadgetFormat
;
192 // Calculate the length of the formatted body string
193 APTR nd
= RawDoFmt(easy
->es_TextFormat
,argList
,(void(*)())SR_LenFunc
,&len
);
196 STRPTR body
= (STRPTR
)AllocVec( len
+2, 0 );
198 // Perform final text formatting
199 if( body
) RawDoFmt(easy
->es_TextFormat
,argList
,(void(*)())SR_CopyFunc
,body
);
200 ctr
->ectr_Body
= body
;
205 // Calculate the length of the formatted gadget string
206 RawDoFmt(easy
->es_GadgetFormat
,nd
,(void(*)())SR_LenFunc
,&len
);
209 STRPTR gadget
= (STRPTR
)AllocVec( len
+2, 0 );
211 // Perform final gadget formatting
212 if( gadget
) RawDoFmt(easy
->es_GadgetFormat
,nd
,(void(*)())SR_CopyFunc
,gadget
);
213 ctr
->ectr_Gadgets
= gadget
;
220 if( *idcmp
& IDCMP_DISKINSERTED
) ctr
->ectr_MonitorDiskInserted
= TRUE
;
221 if( *idcmp
& IDCMP_DISKREMOVED
) ctr
->ectr_MonitorDiskRemoved
= TRUE
;
223 // Clear the *idcmp variable
227 // And now the nice requester
228 val
= EasyCTRequest(ctr
);
235 if( val
== -1 && idcmp
)
237 if( ctr
->ectr_MonitorDiskInserted
) *idcmp
|= IDCMP_DISKINSERTED
;
238 if( ctr
->ectr_MonitorDiskRemoved
) *idcmp
|= IDCMP_DISKREMOVED
;
245 // Yes - free the allocated memory
246 if( ctr
->ectr_Gadgets
) FreeVec(ctr
->ectr_Gadgets
);
247 if( ctr
->ectr_Body
) FreeVec(ctr
->ectr_Body
);
250 // Free the EasyCTRStruct
256 //-------------------------------------
257 LONG
SimpleRequest( struct Window
*wnd
, struct EasyStruct
*easy
, ULONG
*idcmp
, STRPTR reqType
, STRPTR fallBackType
, APTR args
,... )
259 return SimpleRequestArgs( wnd
, easy
, idcmp
, reqType
, fallBackType
, &args
);
261 //-------------------------------------
263 //-------------------------------------
264 VOID
sprintf( STRPTR buf
, const STRPTR fmt
,...)
266 RawDoFmt((const STRPTR
)fmt
,(const STRPTR
*)&fmt
+1,(void(*)())SR_CopyFunc
,buf
);
269 //-------------------------------------
270 ULONG
StrLen( const STRPTR str
)
275 //-------------------------------------
276 STRPTR
StrCopy( const STRPTR str
)
279 if( !str
) return NULL
;
280 if( !*str
) return NULL
;
282 dst
= (STRPTR
)AllocVec(strlen(str
)+1,0);
283 if(dst
) strcpy(dst
,str
);
286 //-------------------------------------
287 STRPTR
NameOfLock( BPTR lock
)
292 if( !lock
) return NULL
;
297 if((n
= (STRPTR
)AllocVec(bufSize
, 0x10000 )))
299 if( NameFromLock( lock
, n
, bufSize
-1 ) == DOSFALSE
)
301 if( IoErr() == ERROR_LINE_TOO_LONG
)
314 //-------------------------------------
315 STRPTR
WBArg2String( struct WBArg
*arg
, LONG numArgs
)
329 NewList((struct List
*)&list
);
331 for( i
=0; i
<numArgs
; i
++)
333 struct WBArgNode
*node
= (struct WBArgNode
*)AllocVec(sizeof(struct WBArgNode
),0x10000);
336 STRPTR n
= NameOfLock(arg
[i
].wa_Lock
);
338 node
->filename
= arg
[i
].wa_Name
;
340 len
+= StrLen( n
)+StrLen(arg
[i
].wa_Name
)+8;
341 AddTail((struct List
*)&list
, (struct Node
*)node
);
345 buf
= (STRPTR
)AllocVec(len
+2,0x10000);
348 struct WBArgNode
*node
;
351 while(( node
= (struct WBArgNode
*)RemHead((struct List
*)&list
)))
353 STRPTR n
= node
->dirname
;
356 if( n
[0] ) strcpy(bufPtr
,n
);
357 AddPart(bufPtr
,node
->filename
,len
-(bufPtr
-buf
));
359 bufPtr
+=strlen(bufPtr
);
360 if(list
.mlh_Head
->mln_Succ
)
370 //-------------------------------------
371 STRPTR
GetFullPath( const STRPTR drw
, const STRPTR file
)
373 ULONG length
= StrLen(drw
)+StrLen(file
)+4;
374 STRPTR fp
= (STRPTR
)AllocVec( length
+1,0 );
379 if( AddPart( fp
, file
, length
)) return fp
;
384 //-------------------------------------
385 STRPTR
BuildIconName( const STRPTR name
)
387 ULONG namelen
=strlen(name
);
388 STRPTR infoname
= AllocVec(namelen
+8,0);
391 strcpy(infoname
,name
);
392 strcpy(infoname
+namelen
,".info");
396 //-------------------------------------
400 STRPTR delprot_body
= "is protected against deletion.\n\nDelete anyway?";
401 STRPTR couldnt_body
= "couldn't be deleted:";
403 //-------------------------------------
417 struct DirList
*parentList
;
429 //-------------------------------------
430 ULONG
PrintError( const ULONG ioerr
, const STRPTR name
, const STRPTR button
)
432 struct EasyStruct easy
;
435 easy
.es_StructSize
= sizeof(struct EasyStruct
);
437 easy
.es_Title
= "Scalos";
438 easy
.es_TextFormat
= "%s %s\n%s";
439 easy
.es_GadgetFormat
= "%s";
441 Fault( ioerr
, NULL
, buffer
,80);
443 return (ULONG
)SimpleRequest( NULL
, &easy
, NULL
, ECTR_TYPE_WARNING
, NULL
, name
, couldnt_body
, buffer
,button
);
445 //-------------------------------------
446 BOOL
IsDeletable( const STRPTR name
, ULONG prot
)
448 if(( prot
& FIBF_DELETE
))
450 BOOL del
=deleteAllProt
;
453 struct EasyStruct easy
;
454 easy
.es_StructSize
= sizeof(struct EasyStruct
);
456 easy
.es_Title
= "Scalos";
457 easy
.es_TextFormat
= "%s\n%s";
458 easy
.es_GadgetFormat
= "%s";
460 switch( SimpleRequest( NULL
, &easy
, NULL
, ECTR_TYPE_WARNING
, NULL
, name
, delprot_body
, "Delete|DeleteAllProtect|Skip"))
470 del
=deleteAllProt
=TRUE
;
479 //-------------------------------------
480 ULONG
Unprotect( const STRPTR name
, const ULONG icon
, ULONG prot
)
482 if(( prot
& FIBF_DELETE
))
485 if(SetProtection(name
,NULL
) != DOSFALSE
) ok
=TRUE
;
488 LONG ioerr
= IoErr();
489 if( ioerr
== ERROR_OBJECT_NOT_FOUND
) ok
= TRUE
;
493 return PrintError(ioerr
,name
,"Skip|Abort");
501 STRPTR infoname
= BuildIconName(name
);
504 if(SetProtection(infoname
,NULL
)== DOSFALSE
)
506 LONG ioerr
= IoErr();
507 if( ioerr
== ERROR_OBJECT_NOT_FOUND
) ok
= TRUE
;
508 else return PrintError(ioerr
,name
,"Skip|Abort");
518 //-------------------------------------
519 BOOL
DeleteTheFile( const STRPTR name
, const ULONG icon
)
522 struct TextExtent te
;
523 ULONG len
= strlen(name
);
526 BOOL onlyicon
= FALSE
;
528 struct IntuiMessage
*imsg
;
530 Move(wnd
->RPort
,offx
+2,offy
+drinfo
->dri_Font
->tf_Baseline
+2+fonty
+1);
531 nc
= TextFit(wnd
->RPort
,(const STRPTR
)name
+len
,len
,&te
,NULL
,-1,wndwidth
-2*offx
-4,fonty
);
532 Text(wnd
->RPort
,(const STRPTR
)name
+len
-nc
,nc
);
534 if( te
.te_Width
< drawerwidth
)
536 EraseRect(wnd
->RPort
,wnd
->RPort
->cp_x
,offy
+3+fonty
,offx
+2+drawerwidth
,offy
+2+2*fonty
);
541 while((imsg
= (struct IntuiMessage
*)GT_GetIMsg(wnd
->UserPort
)))
543 ULONG cl
= imsg
->Class
;
545 if( cl
== IDCMP_SIZEVERIFY
)
547 if(glistAttached
) RemoveGList( wnd
, glist
, -1 );
548 glistAttached
= FALSE
;
558 case IDCMP_CLOSEWINDOW
:
563 if(glistAttached
) RemoveGList( wnd
, glist
, -1 );
564 wndwidth
= wnd
->Width
;
565 wndheight
= wnd
->Height
;
566 EraseRect( wnd
->RPort
, wnd
->BorderLeft
, wnd
->BorderTop
+fonty
+3,
567 wnd
->Width
-wnd
->BorderRight
-1, wnd
->Height
-wnd
->BorderBottom
-1 );
570 AddGList( wnd
, glist
, -1,-1, NULL
);
571 RefreshGList( glist
, wnd
, NULL
, -1 );
572 glistAttached
= TRUE
;
573 SetFont(wnd
->RPort
,drinfo
->dri_Font
);
580 drawerwidth
= te
.te_Width
;
582 if(DeleteFile(name
)==DOSFALSE
)
585 if( ioerr
== ERROR_OBJECT_NOT_FOUND
)
587 if(!DeleteDiskObject(name
))
590 if(ioerr
==ERROR_OBJECT_NOT_FOUND
) ioerr
=0;
601 case ERROR_DELETE_PROTECTED
:
603 BOOL del
=deleteAllProt
;
606 struct EasyStruct easy
;
608 easy
.es_StructSize
= sizeof(struct EasyStruct
);
610 easy
.es_Title
= "Scalos";
611 easy
.es_TextFormat
= "%s\n%s";
612 easy
.es_GadgetFormat
= "%s";
614 switch( SimpleRequest( NULL
, &easy
, NULL
, ECTR_TYPE_WARNING
, NULL
, name
, delprot_body
, "Delete|DeleteAllProtect|Skip"))
625 del
=deleteAllProt
=TRUE
;
633 if( !ok
) if(SetProtection(name
,NULL
) != DOSFALSE
) ok
=TRUE
;
635 if(ok
)//nlyicon || SetProtection(name,NULL) != DOSFALSE )
639 if( icon
|| onlyicon
)
641 ULONG namelen
=strlen(name
);
642 STRPTR infoname
= AllocVec(namelen
+8,0);
646 strcpy(infoname
,name
);
647 strcpy(infoname
+namelen
,".info");
649 if(SetProtection(infoname
,NULL
) != DOSFALSE
)
653 } else SetIoErr(103);
660 if(DeleteDiskObject(name
)) return TRUE
;
663 if(DeleteFile(name
) != DOSFALSE
)
667 if(DeleteDiskObject(name
)) return TRUE
;
679 struct EasyStruct easy;
682 easy.es_StructSize = sizeof(struct EasyStruct);
684 easy.es_Title = "Scalos";
685 easy.es_TextFormat = "%s %s\n%s";
686 easy.es_GadgetFormat = "%s";
688 Fault( ioerr, NULL, buffer,80);
690 return (BOOL)SimpleRequest( NULL, &easy, NULL, ECTR_TYPE_WARNING, NULL, name, couldnt_body, buffer,"Skip|Abort");
692 return (BOOL
)PrintError(ioerr
,name
,"Skip|Abort");
699 DeleteDiskObject(name
);
705 //-------------------------------------
706 BOOL
ReadInDir( struct DirList
*list
, APTR dirPool
)
713 Printf("No Lock!\n");
719 PutStr("Already read!\n");
723 lockName
= NameOfLock(list
->lock
);
726 ULONG lockSize
= strlen(lockName
);
727 APTR filePool
= CreatePool( 0,4096,4096);
730 struct ExAllControl
*eac
;
731 eac
= (struct ExAllControl
*)AllocDosObject(DOS_EXALLCONTROL
,NULL
);
734 struct ExAllData
*ead
;
735 ead
= (struct ExAllData
*)AllocVec( 1032, 0x10000 );
739 struct MinList fileList
;
740 NewList((struct List
*)&fileList
);
742 eac
->eac_LastKey
= 0;
743 eac
->eac_MatchString
= NULL
;
749 struct ExAllData
*ed
= ead
;
750 more
= ExAll( list
->lock
, ed
, 1024, ED_TYPE
, eac
);
751 if((!more
) && (IoErr() != ERROR_NO_MORE_ENTRIES
))
757 if( eac
->eac_Entries
)
761 ULONG nlen
= strlen(ed
->ed_Name
);
762 ULONG len
= nlen
+8+lockSize
;
763 if( ed
->ed_Type
> 0 )
765 struct DirNode
*dir
= (struct DirNode
*)AllocPooled(dirPool
,sizeof(struct DirNode
));
768 STRPTR name
= (STRPTR
)AllocPooled(dirPool
,len
);
771 strcpy(name
,lockName
);
772 AddPart(name
,ed
->ed_Name
,len
);
775 dir
->list
.lock
= Lock( name
, ACCESS_READ
);
776 dir
->list
.read
= FALSE
;
777 dir
->parentList
= list
;
779 NewList((struct List
*)&dir
->list
);
781 AddTail((struct List
*)list
, (struct Node
*)dir
);
786 struct FileNode
*file
= (struct FileNode
*)AllocPooled(filePool
,sizeof(struct FileNode
));
789 STRPTR name
= (STRPTR
)AllocPooled(filePool
,len
);
792 strcpy(name
,lockName
);
793 AddPart(name
,ed
->ed_Name
,len
);
796 file
->nameLen
= strlen(name
);
798 AddTail((struct List
*)&fileList
, (struct Node
*)file
);
809 // Icons aussortieren
810 if( !IsListEmpty((struct List
*)&fileList
))
812 struct FileNode
*node
;
813 node
= (struct FileNode
*)fileList
.mlh_Head
;
814 while(node
->node
.mln_Succ
&& retval
)
816 if( node
->nameLen
> 4 )
818 if( !Stricmp(".info",node
->name
+node
->nameLen
-5))
820 struct FileNode
*fnode
= (struct FileNode
*)fileList
.mlh_Head
;
821 BOOL iconfound
=FALSE
;
822 node
->name
[node
->nameLen
-5]=0;
823 while(fnode
->node
.mln_Succ
)
827 if( !Stricmp(node
->name
,fnode
->name
))
829 fnode
->icon
= iconfound
= TRUE
;
833 fnode
= (struct FileNode
*)fnode
->node
.mln_Succ
;
838 struct DirNode
*dnode
= (struct DirNode
*)list
->list
.mlh_Head
;
839 while(dnode
->node
.mln_Succ
)
841 if( !Stricmp(node
->name
,dnode
->name
))
843 dnode
->icon
= iconfound
= TRUE
;
847 dnode
= (struct DirNode
*)dnode
->node
.mln_Succ
;
853 struct FileNode
*tfn
= node
;
854 node
= (struct FileNode
*)node
->node
.mln_Succ
;
855 Remove((struct Node
*)tfn
);
860 node
= (struct FileNode
*)node
->node
.mln_Succ
;
863 node
= (struct FileNode
*)fileList
.mlh_Head
;
864 while(node
->node
.mln_Succ
&& retval
)
866 retval
= DeleteTheFile(node
->name
,node
->icon
);
867 node
= (struct FileNode
*)node
->node
.mln_Succ
;
872 FreeDosObject(DOS_EXALLCONTROL
,eac
);
874 DeletePool(filePool
);
880 //-------------------------------------
881 BOOL
DeleteDir( struct DirList
*root
, APTR dirPool
)
883 struct DirList
*cl
= root
;
887 // Printf("Readdir: %s 0x%lx\n",NameOfLock(cl->lock),cl);
890 if(!ReadInDir(cl
,dirPool
)) goon
=FALSE
;
893 if( !IsListEmpty((struct List
*)cl
))
895 struct DirNode
*cn
= (struct DirNode
*)cl
->list
.mlh_Head
;
896 cl
= (struct DirList
*)&cn
->list
;
901 struct DirNode
*cn
= (struct DirNode
*)(((ULONG
*)cl
)-3);
902 struct DirNode
*ncn
= (struct DirNode
*)cn
->node
.mln_Succ
;
904 if( !ncn
->node
.mln_Succ
)
908 if( cl
== root
) return TRUE
;
913 PutStr("Ready...\n");
917 if( IsListEmpty((struct List
*)cl
))
923 ncn
= (struct DirNode
*)RemHead((struct List
*)cl
);
924 cn
= (struct DirNode
*)(((ULONG
*)cl
)-3);
926 UnLock(ncn
->list
.lock
);
927 ncn
->list
.lock
= NULL
;
930 goon
= DeleteTheFile(ncn
->name
,ncn
->icon
);
936 } while( IsListEmpty((struct List
*)cl
));
939 ncn
= (struct DirNode
*)cl
->list
.mlh_Head
;
942 Remove((struct Node
*)cn
);
943 UnLock(cn
->list
.lock
);
945 if( goon
) goon
=DeleteTheFile(cn
->name
,cn
->icon
);// break;
948 cl
= (struct DirList
*)&ncn
->list
;
954 //-------------------------------------
956 //-------------------------------------
957 STATIC BOOL
SetupScreen(void)
959 if((scr
= LockPubScreen(NULL
)))
961 if((drinfo
= GetScreenDrawInfo(scr
)))
963 if((visualinfo
= GetVisualInfoA(scr
,NULL
)))
965 Object
*o
= (Object
*)NewObject( NULL
, SYSICLASS
,
966 SYSIA_DrawInfo
,drinfo
,
967 SYSIA_Which
, SIZEIMAGE
,
971 if(!GetAttr( IA_Height
,o
,&sizeheight
)) sizeheight
= 11;
973 } else sizeheight
= 11;
980 //-------------------------------------
981 STATIC VOID
FreeScreen(void)
983 if( visualinfo
) FreeVisualInfo(visualinfo
);
984 if( drinfo
) FreeScreenDrawInfo(scr
,drinfo
);
985 if( scr
) UnlockPubScreen(NULL
,scr
);
987 //-------------------------------------
988 STATIC VOID
Render(void)
990 Move(wnd
->RPort
,offx
+2,offy
+drinfo
->dri_Font
->tf_Baseline
+2);
991 SetABPenDrMd(wnd
->RPort
,drinfo
->dri_Pens
[TEXTPEN
],drinfo
->dri_Pens
[BACKGROUNDPEN
],JAM2
);
992 Text(wnd
->RPort
,"Deleting...",11);
994 //-------------------------------------
995 STATIC BOOL
CreateGadgets(void)
1005 g
= CreateContext( &glist
);
1008 struct NewGadget ng
;
1010 ng
.ng_VisualInfo
= visualinfo
;
1011 ng
.ng_TextAttr
= NULL
;
1012 ng
.ng_GadgetText
= "_Abort";
1014 ng
.ng_Flags
= PLACETEXT_IN
;
1015 ng
.ng_UserData
= NULL
;
1016 ng
.ng_LeftEdge
= offx
+2;
1017 ng
.ng_TopEdge
= offy
+2*fonty
+4;
1018 ng
.ng_Width
= wndwidth
-2*ng
.ng_LeftEdge
;
1019 ng
.ng_Height
= fonty
+6;
1021 g
= CreateGadget( BUTTON_KIND
, g
, &ng
,
1031 //-------------------------------------
1032 STATIC VOID
FreeGUI(void)
1034 if(wnd
) CloseWindow(wnd
);
1035 if(glist
) FreeGadgets(glist
);
1037 //-------------------------------------
1038 STATIC BOOL
SetupGUI(void)
1040 fonty
= drinfo
->dri_Font
->tf_YSize
;
1041 offx
= scr
->WBorLeft
;
1042 offy
= scr
->WBorTop
+ fonty
+ 1;
1045 wndheight
= offy
+ 2*fonty
+ sizeheight
+ 20;
1047 if( CreateGadgets())
1049 wnd
= OpenWindowTags( NULL
,
1050 WA_Left
,(scr
->Width
-wndwidth
)/2,
1051 WA_Top
,(scr
->Height
-wndheight
)/2,
1053 WA_Height
, wndheight
,
1054 WA_IDCMP
, IDCMP_CLOSEWINDOW
|IDCMP_NEWSIZE
|BUTTONIDCMP
|IDCMP_SIZEVERIFY
|IDCMP_VANILLAKEY
,
1056 WA_SizeGadget
, TRUE
,
1057 WA_DepthGadget
,TRUE
,
1058 WA_CloseGadget
, TRUE
,
1062 WA_SizeBBottom
,TRUE
,
1066 WA_NoCareRefresh
,TRUE
,
1070 glistAttached
= TRUE
;
1071 SetFont(wnd
->RPort
,drinfo
->dri_Font
);
1075 glistAttached
= FALSE
;
1080 //-------------------------------------
1081 /*STATIC BOOL HandleWnd(void)
1083 struct IntuiMessage *imsg;
1084 BOOL retVal = FALSE;
1086 while((imsg = GT_GetIMsg(wnd->UserPort)))
1088 ULONG cl = imsg->Class;
1089 UWORD code = imsg->Code;
1090 APTR iaddress = imsg->IAddress;
1092 if( cl == IDCMP_SIZEVERIFY )
1094 if(glistAttached) RemoveGList( wnd, glist, -1 );
1095 glistAttached = FALSE;
1104 case IDCMP_CLOSEWINDOW:
1108 case IDCMP_VANILLAKEY:
1109 if( code == 10 ) retVal = TRUE;
1110 else if( code == 27 )
1117 if(glistAttached) RemoveGList( wnd, glist, -1 );
1118 wndwidth = wnd->Width;
1119 wndheight = wnd->Height;
1120 EraseRect( wnd->RPort, wnd->BorderLeft, wnd->BorderTop+fonty+3,
1121 wnd->Width-wnd->BorderRight-1, wnd->Height-wnd->BorderBottom-1 );
1124 AddGList( wnd, glist, -1,-1, NULL );
1125 RefreshGList( glist, wnd, NULL, -1 );
1126 glistAttached = TRUE;
1127 SetFont(wnd->RPort,drinfo->dri_Font);
1130 glistAttached = FALSE;
1135 case IDCMP_GADGETUP:
1136 switch( ((struct Gadget*)iaddress)->GadgetID )
1146 //-------------------------------------
1148 STRPTR warning_body
= "Warning! You cannot get back what you delete!\nOK to delete:";
1149 STRPTR files_body
= "file(s) and";
1150 STRPTR drawers_body
= "drawer(s) (and there contents)?";
1152 //-------------------------------------
1155 /* if(SetupScreen())
1160 ULONG wndsig = 1UL<<wnd->UserPort->mp_SigBit;
1163 if( appMsgPort ) appsig = 1UL<<appMsgPort->mp_SigBit;
1166 ActivateGadget(commandString,wnd,NULL);
1168 while( ready == FALSE )
1170 ULONG signal = Wait(wndsig|appsig|4096);
1172 if( signal & 4096 ) ready = TRUE;
1173 if( signal & wndsig ) ready = HandleWnd();
1174 if( signal & appsig ) HandleApp();
1180 STRPTR conName = BuildConName("Scalos Output Window",scr);
1183 SystemTags( commandStr,
1185 SYS_Output, Open(conName,MODE_OLDFILE),
1187 SYS_UserShell, TRUE,
1188 stackNum>=4096?NP_StackSize:TAG_IGNORE,stackNum,
1193 SetVar("Scalos_last_cmd",commandStr,strlen(commandStr),GVF_GLOBAL_ONLY);
1194 FreeVec(commandStr);
1201 if(WorkbenchBase)CloseLibrary(WorkbenchBase);*/
1203 //-------------------------------------
1204 void wbmain(struct WBStartup
*wbs
)
1207 if( wbs
->sm_NumArgs
> 1 )
1209 if((IconBase
= OpenLibrary("icon.library",37)))
1211 LONG numArgs
=wbs
->sm_NumArgs
;
1212 struct WBArg
*wbarg
;
1216 wbarg
= (struct WBArg
*)AllocVec((numArgs
+2)*sizeof(struct WBArg
),0x10000);
1224 for( i
=1; i
<numArgs
; i
++)
1226 if(!(wbarg
[i
-1].wa_Lock
= /*((Lock("RAM:Unnamed1",ACCESS_READ)))/ */DupLock(wbs
->sm_ArgList
[i
].wa_Lock
)))
1232 if(wbs
->sm_ArgList
[i
].wa_Name
)
1234 if(*wbs
->sm_ArgList
[i
].wa_Name
)
1236 if(!(wbarg
[i
-1].wa_Name
= StrCopy(wbs
->sm_ArgList
[i
].wa_Name
)))
1251 ReplyMsg((struct Message
*)wbs
);
1258 struct EasyStruct easy
;
1260 easy
.es_StructSize
= sizeof(struct EasyStruct
);
1262 easy
.es_Title
= "Scalos";
1263 easy
.es_TextFormat
= "%s\n%ld %s %ld %s";
1264 easy
.es_GadgetFormat
= "%s";
1266 if( SimpleRequest( NULL
, &easy
, NULL
, ECTR_TYPE_WARNING
, NULL
, warning_body
, num_files
, files_body
, num_drws
, drawers_body
, "OK|Cancel"))
1271 for( i
=0; i
<numArgs
&& !ready
; i
++)
1275 if(wbarg
[i
].wa_Name
)
1277 if(*wbarg
[i
].wa_Name
) drawer
= FALSE
;
1282 APTR dirPool
= CreatePool(NULL
,4096,4096);
1285 struct DirList list
;
1286 STRPTR name
=NameOfLock(wbarg
[i
].wa_Lock
);
1289 struct FileInfoBlock
*fib
= (struct FileInfoBlock
*)AllocDosObject(DOS_FIB
,NULL
);
1292 if(Examine( wbarg
[i
].wa_Lock
,fib
)!=DOSFALSE
)
1294 if(IsDeletable(name
,fib
->fib_Protection
))
1296 NewList((struct List
*)&list
);
1298 list
.lock
= wbarg
[i
].wa_Lock
;//Lock("RAM:",ACCESS_READ);
1301 DeleteDir(&list
,dirPool
);
1303 UnLock(wbarg
[i
].wa_Lock
);
1304 wbarg
[i
].wa_Lock
=NULL
;
1306 switch(Unprotect(name
,TRUE
,fib
->fib_Protection
))
1308 case 0: ready
=TRUE
;break;
1309 case 2: if(!DeleteTheFile(name
,TRUE
))ready
=TRUE
;
1312 } else PrintError(IoErr(),name
,"OK");
1316 DeletePool(dirPool
);
1320 STRPTR dname
=NameOfLock(wbarg
[i
].wa_Lock
);
1323 ULONG len
=strlen(dname
)+8+strlen(wbarg
[i
].wa_Name
);
1324 STRPTR name
= (STRPTR
)AllocVec(len
,0);
1328 AddPart(name
,wbarg
[i
].wa_Name
,len
);
1329 if(!DeleteTheFile(name
,TRUE
))
1345 for( i
=0; i
<numArgs
; i
++)
1347 if(wbarg
[i
].wa_Lock
) UnLock(wbarg
[i
].wa_Lock
);
1348 if(wbarg
[i
].wa_Name
) FreeVec(wbarg
[i
].wa_Name
);
1352 CloseLibrary(IconBase
);
1357 //-------------------------------------