2 Copyright © 2003-2016, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
9 #include <aros/debug.h>
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <proto/muimaster.h>
14 #include <proto/workbench.h>
15 #include <proto/dos.h>
16 #include <proto/alib.h>
17 #include <proto/icon.h>
20 #include <dos/datetime.h>
21 #include <exec/memory.h>
22 #include <libraries/asl.h>
23 #include <libraries/commodities.h>
24 #include <libraries/mui.h>
25 #include <workbench/startup.h>
26 #include <workbench/workbench.h>
27 #include <workbench/icon.h>
28 #include <devices/inputevent.h>
30 #include <mui/TextEditor_mcc.h>
31 #include <zune/iconimage.h>
39 #define RETURNID_SLEEP 1
40 #define RETURNID_WAKE 2
41 #define RETURNID_ABOUT 3
42 #define RETURNID_NEWKEY 4
43 #define RETURNID_DELKEY 5
44 #define RETURNID_LVACK 6
45 #define RETURNID_STRINGACK 7
46 #define RETURNID_SAVE 8
47 #define RETURNID_TOOLACK 9
48 #define RETURNID_STACKACK 10
49 #define RETURNID_COMMENTACK 11
50 #define RETURNID_QUERYVERSION 12
51 #define RETURNID_PROTECT 13
52 #define RETURNID_SCANSIZE 14
53 #define RETURNID_OPENPATH 15
55 #define MAX_PATH_LEN 1024
56 #define MAX_TOOLTYPE_LINE 256
57 #define BUFFERSIZE 1024
59 #define USE_TEXTEDITOR 1
64 static Object
*window
, *commentspace
, *filename_string
, *stackspace
, *savebutton
;
65 static Object
*readobject
, *writeobject
, *executeobject
, *deleteobject
;
66 static Object
*scriptobject
, *pureobject
, *archiveobject
, *sizespace
= NULL
;
69 struct Process
*scanProcess
;
76 static struct DirScanProcess
*scanStruct
= NULL
;
79 static Object
*editor
, *slider
;
81 static Object
*list
, *editor
, *liststr
;
84 BOOL file_altered
= FALSE
;
85 BOOL icon_altered
= FALSE
;
86 char loadedcomment
[MAXCOMMENTLENGTH
];
88 void getReadableSize(UBYTE
*buf
, UQUAD size
, BOOL accurate
)
102 /*if (size >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024))
105 array.val = size >> 60;
106 d = (size * 10 + ((1024 * 1024 * 1024 * 1024 * 1024 * 1024) / 2)) / (1024 * 1024 * 1024 * 1024 * 1024 * 1024);
110 else if (size >= (1024 * 1024 * 1024 * 1024 * 1024))
113 array.val = size >> 50;
114 d = (size * 10 + ((1024 * 1024 * 1024 * 1024 * 1024) / 2)) / (1024 * 1024 * 1024 * 1024 * 1024);
118 else if (size >= (1024 * 1024 * 1024 * 1024))
121 array.val = size >> 40;
122 d = (size * 10 + ((1024 * 1024 * 1024 * 1024) / 2)) / (1024 * 1024 * 1024 * 1024);
126 if (size
>= (1024 * 1024 * 1024))
129 array
.val
= size
>> 30;
130 d
= (size
* 10 + ((1024 * 1024 * 1024) / 2)) / (1024 * 1024 * 1024);
134 else if (size
>= (1024 * 1024))
137 array
.val
= size
>> 20;
138 d
= (size
* 10 + ((1024 * 1024) / 2)) / (1024 * 1024);
142 else if (size
>= 1024)
145 array
.val
= size
>> 10;
146 d
= (size
* 10 + (1024 / 2)) / 1024;
162 if (!array
.dec
&& (d
> array
.val
* 10))
171 RawDoFmt(array
.dec
? "%lu.%lu" : "%lu", (RAWARG
)&array
, NULL
, buf
);
176 sprintf((char *)buf
," %s", ch
);
179 #define kExallBufSize (4096)
181 UQUAD
calculateDirectorySize(struct DirScanProcess
*scan
, UQUAD base
, CONST_STRPTR directory
, UQUAD
* lastrefreshsize
)
183 UBYTE
*buffer
= NULL
;
184 BPTR directoryLock
= BNULL
;
185 UQUAD directorySize
= 0;
188 D(bug("[WBInfo] calculateDirectorySize('%s')\n", directory
));
190 directoryLock
= Lock(directory
, SHARED_LOCK
);
192 /* Allocate buffer for ExAll */
193 if ((buffer
= AllocVec(kExallBufSize
, MEMF_CLEAR
|MEMF_PUBLIC
)) == NULL
)
195 UnLock(directoryLock
);
199 struct ExAllData
*ead
= (struct ExAllData
*)buffer
;
200 struct ExAllControl
*eac
= AllocDosObject(DOS_EXALLCONTROL
, NULL
);
201 eac
->eac_LastKey
= 0;
203 struct ExAllData
*oldEad
= ead
;
208 loop
= ExAll(directoryLock
, ead
, kExallBufSize
, ED_COMMENT
, eac
);
210 if(!loop
&& IoErr() != ERROR_NO_MORE_ENTRIES
) break;
212 if(eac
->eac_Entries
!= 0)
216 if (ead
->ed_Type
== ST_FILE
)
218 directorySize
+= ead
->ed_Size
;
219 /* Refresh size only every 25% grow */
220 if ((((base
+ directorySize
) * 100) / (*lastrefreshsize
)) > 125) /* 25 % */
222 getReadableSize(scan
->scanSize
, (base
+ directorySize
), FALSE
);
223 set(sizespace
, MUIA_Text_Contents
, (IPTR
) scan
->scanSize
);
224 *lastrefreshsize
= base
+ directorySize
;
227 else if (ead
->ed_Type
== ST_USERDIR
)
229 ULONG subdirlen
= strlen(directory
) + strlen(ead
->ed_Name
) + 1;
230 char * subdirectory
= AllocVec(subdirlen
+ 1, MEMF_CLEAR
);
231 CopyMem(directory
, subdirectory
, strlen(directory
));
232 AddPart(subdirectory
, ead
->ed_Name
, subdirlen
+ 1);
233 directorySize
+= calculateDirectorySize(scan
, (base
+ directorySize
), subdirectory
, lastrefreshsize
);
236 } while((ead
!= NULL
) && (scan
->scanState
== SCANRUN
));
238 } while((loop
) && (scan
->scanState
== SCANRUN
));
240 FreeDosObject(DOS_EXALLCONTROL
, eac
);
241 UnLock(directoryLock
);
244 return directorySize
;
248 * child process to calculate directory content size..
250 AROS_UFH3(void, scanDir_Process
,
251 AROS_UFHA(STRPTR
, argPtr
, A0
),
252 AROS_UFHA(ULONG
, argSize
, D0
),
253 AROS_UFHA(struct ExecBase
*, SysBase
, A6
))
257 struct Task
*taskSelf
= FindTask(NULL
);
258 struct DirScanProcess
*scan
= taskSelf
->tc_UserData
;
259 UQUAD directorySize
= 0;
261 if (scan
->scanState
== SCANRUN
)
263 UQUAD lastrefreshsize
= 1;
264 D(bug("[WBInfo] scanDir_Process('%s')\n", scan
->scanDir
));
265 scan
->scanSize
= AllocVec(64, MEMF_CLEAR
);
266 directorySize
= calculateDirectorySize(scan
, directorySize
, scan
->scanDir
, &lastrefreshsize
);
267 D(bug("[WBInfo] scanDir_Process: End size = %d bytes\n", directorySize
));
268 getReadableSize(scan
->scanSize
, directorySize
, TRUE
);
269 set(sizespace
, MUIA_Text_Contents
, (IPTR
) scan
->scanSize
);
270 FreeVec(scan
->scanSize
);
272 scan
->scanProcess
= NULL
;
277 UBYTE
**BuildToolTypes(UBYTE
**src_ttypes
)
280 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
281 STRPTR contents
, sp
, *dst_ttypes
;
284 if (!pool
) return NULL
;
285 contents
= (STRPTR
)DoMethod(editor
, MUIM_TextEditor_ExportText
);
287 if (!contents
|| !contents
[0])
295 while((sp
= strchr(sp
, '\n')))
301 dst_ttypes
= AllocPooled(pool
, (lines
+ 3) * sizeof(STRPTR
));
309 *dst_ttypes
++ = (STRPTR
)pool
;
310 *dst_ttypes
++ = (STRPTR
)contents
;
312 for(sp
= contents
, lines
= 0; sp
; lines
++)
314 dst_ttypes
[lines
] = sp
;
315 sp
= strchr(sp
, '\n');
321 dst_ttypes
[lines
] = 0;
325 APTR pool
= CreatePool(MEMF_CLEAR
, 200, 200);
326 Object
*listobj
= list
;
327 WORD list_index
= 0, num_ttypes
= 0, alloc_ttypes
= 10;
330 if (!pool
) return NULL
;
332 dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 2) * sizeof(UBYTE
*));
339 get(listobj
, MUIA_List_Entries
, &list_index
);
340 while(num_ttypes
<list_index
)
343 DoMethod(listobj
, MUIM_List_GetEntry
, num_ttypes
, (IPTR
)&text
);
344 if (num_ttypes
>= alloc_ttypes
)
346 UBYTE
**new_dst_ttypes
= AllocPooled(pool
, (alloc_ttypes
+ 10 + 2) * sizeof(UBYTE
*));
352 CopyMem(dst_ttypes
+ 1, new_dst_ttypes
+ 1, alloc_ttypes
* sizeof(UBYTE
*));
353 dst_ttypes
= new_dst_ttypes
;
356 dst_ttypes
[num_ttypes
+ 1] = AllocPooled(pool
, strlen(text
) + 1);
357 if (!dst_ttypes
[num_ttypes
+ 1])
362 CopyMem(text
, dst_ttypes
[num_ttypes
+ 1], strlen(text
) + 1);
363 D(bug("[WBInfo] tooltype #%ld %s\n", num_ttypes
+ 1, text
));
366 dst_ttypes
[0] = (APTR
)pool
;
367 return dst_ttypes
+ 1;
371 void FreeToolTypes(UBYTE
**ttypes
)
376 FreeVec((APTR
)ttypes
[-1]);
377 DeletePool((APTR
)ttypes
[-2]);
382 DeletePool((APTR
)ttypes
[-1]);
387 void SaveIcon(struct DiskObject
*icon
, STRPTR name
, BPTR cd
)
389 STRPTR tool
= NULL
, stack
= NULL
;
392 UBYTE
**ttypes
= NULL
, **old_ttypes
= NULL
;
394 restored_cd
= CurrentDir(cd
);
396 switch(icon
->do_Type
)
399 get(filename_string
, MUIA_String_Contents
, &tool
);
400 icon
->do_DefaultTool
= tool
;
401 get(stackspace
, MUIA_String_Contents
, &stack
);
403 icon
->do_StackSize
= (LONG
)ls
;
406 get(stackspace
, MUIA_String_Contents
, &stack
);
408 icon
->do_StackSize
= (LONG
)ls
;
412 old_ttypes
= (UBYTE
**)icon
->do_ToolTypes
;
413 ttypes
= BuildToolTypes(old_ttypes
);
414 icon
->do_ToolTypes
= ttypes
;
416 PutIconTags(name
, icon
, TAG_DONE
);
418 icon
->do_ToolTypes
= old_ttypes
;
421 FreeToolTypes(ttypes
);
423 CurrentDir(restored_cd
);
424 icon_altered
= FALSE
;
427 void SaveFile(struct AnchorPath
* ap
, BPTR cd
)
429 ULONG protection
= 0;
432 restored_cd
= CurrentDir(cd
);
434 get(commentspace
, MUIA_String_Contents
, &text
);
436 SetComment(ap
->ap_Buf
, text
);
438 if (XGET(scriptobject
, MUIA_Selected
))
439 protection
|= FIBF_SCRIPT
;
440 if (XGET(pureobject
, MUIA_Selected
))
441 protection
|= FIBF_PURE
;
442 if (XGET(archiveobject
, MUIA_Selected
))
443 protection
|= FIBF_ARCHIVE
;
445 if (! XGET(readobject
, MUIA_Selected
))
446 protection
|= FIBF_READ
;
447 if (! XGET(writeobject
, MUIA_Selected
))
448 protection
|= FIBF_WRITE
;
449 if (! XGET(executeobject
, MUIA_Selected
))
450 protection
|= FIBF_EXECUTE
;
451 if (! XGET(deleteobject
, MUIA_Selected
))
452 protection
|= FIBF_DELETE
;
454 SetProtection(ap
->ap_Buf
, protection
);
456 CurrentDir(restored_cd
);
457 file_altered
= FALSE
;
461 void ListToString(void)
464 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
467 set(liststr
, MUIA_String_Contents
, text
);
468 nnset(liststr
, MUIA_Disabled
, FALSE
);
469 set(window
, MUIA_Window_ActiveObject
, (IPTR
)liststr
);
473 void StringToKey(void)
480 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
) &text
);
483 get(liststr
, MUIA_String_Contents
, &input
);
484 DoMethod(list
, MUIM_List_InsertSingle
, input
, MUIV_List_Insert_Active
);
485 set(list
, MUIA_List_Active
, MUIV_List_Active_Down
);
486 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
487 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
488 nnset(liststr
, MUIA_Disabled
, TRUE
);
489 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
495 nnset(liststr
, MUIA_String_Contents
, "");
496 nnset(liststr
, MUIA_Disabled
, FALSE
);
497 DoMethod(list
, MUIM_List_InsertSingle
, "", MUIV_List_Insert_Bottom
);
498 nnset(list
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
499 set(window
, MUIA_Window_ActiveObject
, (IPTR
) liststr
);
505 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
509 DoMethod(list
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
510 DoMethod(list
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, (IPTR
)&text
);
513 nnset(liststr
, MUIA_String_Contents
, (IPTR
) "");
514 nnset(liststr
, MUIA_Disabled
, TRUE
);
523 static char * GetVersion(STRPTR name
, BPTR cd
)
525 D(bug("[WBINFO/Getversion] Name %s\n", name
));
526 STRPTR commandline
= NULL
;
527 ULONG commandlineSize
;
528 static TEXT result
[100]; // must be static because we return its address
529 char *retval
= result
;
530 TEXT tmpfilename
[40];
534 BPTR restored_cd
= (BPTR
)-1;
538 D(bug("[WBINFO/Getversion] Name is Null\n"));
542 memset(result
, 0, sizeof(result
));
545 commandlineSize
= strlen(name
) + 20;
546 commandline
= AllocVec(commandlineSize
, MEMF_CLEAR
);
547 if (commandline
== NULL
)
549 D(bug("[WBInfo/GetVersion] Can't allocate RAM for commandline\n"));
553 restored_cd
= CurrentDir(cd
);
555 //search for non-existing temp file name
561 D(bug("[WBINFO/Getversion] Can't find non-existing tmpfile"));
564 sprintf(tmpfilename
, "t:tmp_version_%d", nr
);
565 output
= Open(tmpfilename
, MODE_OLDFILE
);
570 } while (output
!= BNULL
);
572 D(bug("[WBInfo/Getversion] tmpfilename %s\n", tmpfilename
));
573 output
= Open(tmpfilename
, MODE_NEWFILE
);
576 D(bug("[WBInfo/Getversion] Can't create tmpfile\n"));
581 sprintf(commandline
, "c:version \"%s\" full", name
);
582 D(bug("[WBInfo/GetVersion] Commandline %s\n", commandline
));
583 if (SystemTags(commandline
,
584 SYS_Output
, (IPTR
) output
,
585 //SYS_Error, (IPTR) NULL,
589 D(bug("[WBInfo/Getversion] SystemTags failed\n"));
593 // Seek didn't work for me on RAM-Disk, so we reopen the file
595 output
= Open(tmpfilename
, MODE_OLDFILE
);
598 D(bug("[WBInfo/GetVersion] Can't open tmpfile\n"));
602 if (Read(output
, result
, sizeof(result
) - 1) == -1)
604 D(bug("[WBInfo/GetVersion] Can't read from tmpfile\n"));
607 D(bug("[WBInfo/GetVersion] Result %s\n", result
));
609 // remove illegal chars (e.g. newline) from result
610 for (i
= 0 ; result
[i
] != 0 ; i
++)
616 // set string pointer after program name
617 while (*retval
!= ' ')
621 FreeVec(commandline
);
625 DeleteFile(tmpfilename
);
627 if (restored_cd
!= (BPTR
)-1)
628 CurrentDir(restored_cd
);
633 static void AddStackField(Object
* application
, Object
* group
, STRPTR stack
)
635 Object
* stacklabel
= NULL
;
637 stackspace
= (Object
*)StringObject
,
639 MUIA_String_MaxLen
, 16,
640 MUIA_String_Contents
, (IPTR
)stack
,
641 MUIA_String_Format
, MUIV_String_Format_Right
,
642 MUIA_String_Accept
, (IPTR
)"0123456789",
645 stacklabel
= MUI_MakeObject(MUIO_Label
, _(MSG_STACK
), NULL
);
647 if ((stackspace
!= NULL
) && (stacklabel
!= NULL
))
649 DoMethod(group
, MUIM_Group_InitChange
);
650 DoMethod(group
, OM_ADDMEMBER
, stacklabel
);
651 DoMethod(group
, OM_ADDMEMBER
, stackspace
);
652 DoMethod(group
, MUIM_Group_ExitChange
);
653 SetAttrs(stackspace
, MUIA_CycleChain
, 1, TAG_DONE
);
654 DoMethod(stackspace
, MUIM_Notify
,
655 MUIA_String_Acknowledge
, MUIV_EveryTime
,
656 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STACKACK
);
660 static void AddToolField(Object
* application
, Object
* group
, STRPTR tool
)
662 Object
* toolspace
= MUI_NewObject(MUIC_Popasl
, ASLFR_DoSaveMode
, TRUE
,
663 MUIA_Popstring_String
, (IPTR
)(filename_string
= (Object
*)StringObject
,
665 MUIA_String_MaxLen
, MAX_PATH_LEN
,
666 MUIA_String_Contents
, (IPTR
)tool
,
668 MUIA_Popstring_Button
, (IPTR
) PopButton(MUII_PopFile
), TAG_DONE
);
670 Object
* toollabel
= MUI_MakeObject(MUIO_Label
, _(MSG_DEFTOOL
), NULL
);
672 if ((toolspace
!= NULL
) && (toollabel
!= NULL
)&&(filename_string
!= NULL
))
674 DoMethod(group
, MUIM_Group_InitChange
);
675 DoMethod(group
, OM_ADDMEMBER
, toollabel
);
676 DoMethod(group
, OM_ADDMEMBER
, toolspace
);
677 DoMethod(group
, MUIM_Group_ExitChange
);
679 set(toolspace
, MUIA_CycleChain
, 1);
680 DoMethod(filename_string
, MUIM_Notify
,
681 MUIA_String_Acknowledge
, MUIV_EveryTime
,
682 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_TOOLACK
);
686 static void AddEmptySpace(Object
* group
)
688 Object
* emptyspace
= MUI_NewObject(MUIC_Rectangle
, TAG_DONE
);
689 if ((emptyspace
!= NULL
))
691 DoMethod(group
, MUIM_Group_InitChange
);
692 DoMethod(group
, OM_ADDMEMBER
, emptyspace
);
693 DoMethod(group
, MUIM_Group_ExitChange
);
697 int main(int argc
, char **argv
)
699 Object
*application
, *grouptool
, *groupstack
= NULL
;
700 Object
*registergroup
= NULL
, *infomenu
= NULL
, *protectmenu
= NULL
, *toolmenu
= NULL
;
701 Object
*datespace
= NULL
, *typespace
= NULL
, *quit
= NULL
, *aboutmenu
= NULL
;
702 Object
*sizegrp
= NULL
, *versiongrp
= NULL
, *versionspace
= NULL
;
703 Object
*cancelbutton
= NULL
;
704 Object
*pathspace
= NULL
, *btnopenpath
;
706 Object
*newkey
= NULL
, *delkey
= NULL
;
708 struct WBStartup
*startup
;
709 struct DiskObject
*icon
= NULL
;
710 struct AnchorPath
*ap
= NULL
;
711 struct DateStamp
*ds
= NULL
;
716 STRPTR name
= NULL
, file
= NULL
, type
= NULL
;
721 char deftool
[MAX_PATH_LEN
];
723 char date
[LEN_DATSTRING
];
724 char time
[LEN_DATSTRING
];
725 char dow
[LEN_DATSTRING
];
726 char datetime
[2*LEN_DATSTRING
];
727 UBYTE flags
[8] = {0}, lname
[MAXFILENAMELENGTH
];
729 char *pages
[] = {_(MSG_INFORMATION
),_(MSG_PROTECTION
),_(MSG_TOOLTYPES
),NULL
};
734 _(MSG_DRAWER
), /* 2 */
736 _(MSG_PROJECT
), /* 4 */
737 _(MSG_GARBAGE
), /* 5 */
738 _(MSG_DEVICE
), /* 6 */
740 _(MSG_APPICON
) /* 8 */
745 int retval
= RETURN_OK
;
749 /* start from wanderer only */
750 PrintFault(ERROR_FILE_NOT_OBJECT
, argv
[0]);
751 retval
= RETURN_FAIL
;
755 startup
= (struct WBStartup
*) argv
;
757 if (startup
->sm_NumArgs
< 2)
759 /* need atleast 1 arg */
760 PrintFault(ERROR_REQUIRED_ARG_MISSING
, argv
[0]);
761 D(bug("[WBInfo] required arg missing\n"));
762 retval
= RETURN_FAIL
;
766 lock
= startup
->sm_ArgList
[1].wa_Lock
;
767 NameFromLock(lock
, lname
, MAXFILENAMELENGTH
);
768 D(bug("[WBInfo] arg parent lock 0x%p: '%s'\n", lock
, lname
));
770 if (startup
->sm_ArgList
[1].wa_Name
!= NULL
)
772 if ((name
= AllocVec(strlen(startup
->sm_ArgList
[1].wa_Name
) + 1, MEMF_CLEAR
)) != NULL
)
774 CopyMem(startup
->sm_ArgList
[1].wa_Name
, name
, strlen(startup
->sm_ArgList
[1].wa_Name
));
775 if ((strlen(name
) > 5)
776 && (strcmp(name
+ strlen(name
) - 5, ".info") == 0))
778 file
= AllocVec(strlen(name
) - 4, MEMF_CLEAR
);
779 CopyMem(name
, file
, strlen(name
) - 5);
783 file
= AllocVec(strlen(name
) + 1, MEMF_CLEAR
);
784 CopyMem(name
, file
, strlen(name
));
786 D(bug("[WBInfo] arg name 0x%p: '%s', file = '%s'\n", name
, name
, file
));
789 cd
= CurrentDir(lock
);
792 /* directory not found*/
793 PrintFault(ERROR_DIR_NOT_FOUND
, argv
[0]);
794 D(bug("[WBInfo] dir not found\n"));
795 retval
= RETURN_FAIL
;
799 ap
= AllocVec(sizeof(struct AnchorPath
) + MAX_PATH_LEN
, MEMF_CLEAR
);
802 PrintFault(ERROR_NO_FREE_STORE
, argv
[0]);
803 D(bug("[WBInfo] no free store\n"));
804 retval
= RETURN_FAIL
;
808 ap
->ap_Strlen
= MAX_PATH_LEN
;
810 if (0 != MatchFirst(name
, ap
))
812 D(bug("[WBInfo] pass to diskinfo\n"));
814 "WANDERER:Tools/DiskInfo",
815 WBOPENA_ArgLock
, (IPTR
) startup
->sm_ArgList
[1].wa_Lock
,
816 WBOPENA_ArgName
, (IPTR
) startup
->sm_ArgList
[1].wa_Name
,
823 ap
->ap_BreakBits
= SIGBREAKF_CTRL_C
;
825 if (!(ap
->ap_Flags
& APF_DIDDIR
))
827 D(bug("[WBInfo] scan file\n"));
829 sprintf(loadedcomment
,"%s",ap
->ap_Info
.fib_Comment
);
831 /* fill date and time */
832 ds
= &ap
->ap_Info
.fib_Date
;
833 DateStamp((struct DateStamp
*)&dt
);
834 CopyMem(ds
, &dt
.dat_Stamp
, sizeof(struct DateStamp
));
835 dt
.dat_Format
= FORMAT_DOS
;
838 dt
.dat_StrDate
= date
;
839 dt
.dat_StrTime
= time
;
844 sprintf(datetime
, "%s %s", time
, date
);
847 getReadableSize(size
, ap
->ap_Info
.fib_Size
, TRUE
);
849 /* fill protection */
850 protection
= ap
->ap_Info
.fib_Protection
;
852 /* Convert the protection bits to a boolean */
853 flags
[0] = protection
& FIBF_SCRIPT
? 1 : 0; /* s */
854 flags
[1] = protection
& FIBF_PURE
? 1 : 0; /* p */
855 flags
[2] = protection
& FIBF_ARCHIVE
? 1 : 0; /* a */
857 /* The following flags are high-active! */
858 flags
[3] = protection
& FIBF_READ
? 0 : 1; /* r */
859 flags
[4] = protection
& FIBF_WRITE
? 0 : 1; /* w */
860 flags
[5] = protection
& FIBF_EXECUTE
? 0 : 1; /* e */
861 flags
[6] = protection
& FIBF_DELETE
? 0 : 1; /* d */
862 flags
[7] = 0x00; /* h */
866 icon
= GetIconTags(file
,
867 ICONGETA_FailIfUnavailable
, FALSE
,
868 ICONGETA_IsDefaultIcon
, FALSE
,
873 D(bug("[WBInfo] file has icon\n"));
874 type
= (char *) typeNames
[icon
->do_Type
];
875 D(bug("[WBInfo] icon type is: %s\n", type
));
876 sprintf(stack
, "%d", (int)icon
->do_StackSize
);
877 if (icon
->do_DefaultTool
)
878 sprintf(deftool
, "%s", icon
->do_DefaultTool
);
882 PrintFault(ERROR_OBJECT_WRONG_TYPE
, argv
[0]);
884 retval
= RETURN_FAIL
;
888 if (icon
->do_Type
== 2)
890 sizespace
= (Object
*)TextObject
,
892 MUIA_Background
, MUII_TextBack
,
893 MUIA_Text_PreParse
, (IPTR
) "\33r",
894 MUIA_Text_Contents
, (IPTR
) "?",
895 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
898 versionspace
= (Object
*)TextObject
,
900 MUIA_Background
, MUII_TextBack
,
901 MUIA_Text_PreParse
, (IPTR
) "\33r",
902 MUIA_Text_Contents
, (IPTR
) "N/A",
907 sizespace
= (Object
*)TextObject
,
909 MUIA_Background
, MUII_TextBack
,
910 MUIA_Text_PreParse
, (IPTR
) "\33r",
911 MUIA_Text_Contents
, (IPTR
) size
,
914 versionspace
= (Object
*)TextObject
,
916 MUIA_Background
, MUII_TextBack
,
917 MUIA_Text_PreParse
, (IPTR
) "\33r",
918 MUIA_Text_Contents
, (IPTR
) "?",
919 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
923 if (icon
->do_Type
!=WBDRAWER
)
925 sprintf(pathname
, "%s",lname
);
931 sprintf(pathname
, "%s",lname
);
932 ch
= strrchr (pathname
, path_y
);
933 path_x
= strlen (ch
);
936 sprintf(pathname
, "%s/%s", lname
, name
);
938 sprintf(pathname
, "%s%s", lname
, name
);
942 application
= (Object
*)ApplicationObject
,
943 MUIA_Application_Title
, __(MSG_TITLE
),
944 MUIA_Application_Version
, (IPTR
) "$VER: Info 0.8 ("ADATE
") © 2003-2016 The AROS Dev Team",
945 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
946 MUIA_Application_Base
, (IPTR
) "INFO",
947 MUIA_Application_Menustrip
, (IPTR
) MenustripObject
,
948 MUIA_Family_Child
, (IPTR
) MenuObject
,
949 MUIA_Menu_Title
, __(MSG_PROJECT
),
950 MUIA_Family_Child
, (IPTR
)(infomenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
951 __(MSG_INFORMATION
), MUIA_Menuitem_Shortcut
, (IPTR
) "I", End
),
952 MUIA_Family_Child
, (IPTR
)(protectmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
953 __(MSG_PROTECTION
),MUIA_Menuitem_Shortcut
, (IPTR
) "P", End
),
954 MUIA_Family_Child
, (IPTR
)(toolmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
955 __(MSG_TOOLTYPES
),MUIA_Menuitem_Shortcut
, (IPTR
) "T", End
),
956 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
957 MUIA_Family_Child
, (IPTR
) (aboutmenu
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
958 __(MSG_ABOUT
), (IPTR
) MUIA_Menuitem_Shortcut
, (IPTR
) "?", End
),
959 MUIA_Family_Child
, (IPTR
) MenuitemObject
, MUIA_Menuitem_Title
, ~0, End
,
960 MUIA_Family_Child
, (IPTR
) (quit
= (Object
*)MenuitemObject
, MUIA_Menuitem_Title
,
961 __(MSG_QUIT
), MUIA_Menuitem_Shortcut
, (IPTR
) "Q", End
),
964 SubWindow
, (IPTR
) (window
= (Object
*)WindowObject
,
965 MUIA_Window_Title
, (IPTR
) __(MSG_TITLE
),
966 MUIA_Window_ID
, MAKE_ID('I','N','F','O'),
967 MUIA_Window_Activate
, TRUE
,
968 WindowContents
, (IPTR
) VGroup
,
969 Child
, (IPTR
) HGroup
,
970 Child
, (IPTR
) VGroup
,
971 Child
, (IPTR
) IconImageObject
,
972 MUIA_InputMode
, MUIV_InputMode_Toggle
,
973 MUIA_IconImage_File
, (IPTR
) file
,
976 Child
, (IPTR
) VGroup
,
977 Child
, (IPTR
) TextObject
,
979 MUIA_Background
, MUII_TextBack
,
980 MUIA_Text_PreParse
, (IPTR
) "\33l",
981 MUIA_Text_Contents
, (IPTR
) FilePart(file
),
985 Child
, (IPTR
) (registergroup
= (Object
*)RegisterGroup(pages
),
987 Child
, (IPTR
) HGroup
, /* hgroup information pannel */
988 Child
, (IPTR
) VGroup
,
989 Child
, (IPTR
) HGroup
,
990 Child
, (IPTR
) ColGroup(2),
991 Child
, (IPTR
) Label2(__(MSG_TYPE
)),
992 Child
, (IPTR
) (typespace
= (Object
*)TextObject
,
994 MUIA_Background
, MUII_TextBack
,
995 MUIA_Text_PreParse
, (IPTR
) "\33r",
996 MUIA_Text_Contents
, (IPTR
) type
,
998 Child
, (IPTR
) Label2(__(MSG_DATE
)),
999 Child
, (IPTR
) (datespace
= (Object
*)TextObject
,
1001 MUIA_Background
, MUII_TextBack
,
1002 MUIA_Text_PreParse
, (IPTR
) "\33r",
1003 MUIA_Text_Contents
, (IPTR
) datetime
,
1005 Child
, (IPTR
) Label2(__(MSG_VERSION
)),
1006 Child
, (IPTR
) (versiongrp
= (Object
*)HGroup
,
1007 Child
, (IPTR
) versionspace
,
1009 Child
, (IPTR
) Label2(__(MSG_SIZE
)),
1010 Child
, (IPTR
) (sizegrp
= (Object
*)HGroup
,
1011 Child
, (IPTR
) sizespace
,
1013 Child
, (IPTR
) Label2(__(MSG_PATH
)),
1014 Child
, (IPTR
) HGroup
,
1015 Child
, (IPTR
) (pathspace
= (Object
*)StringObject
,
1017 MUIA_String_Contents
, (IPTR
)pathname
,
1020 Child
, (IPTR
) (btnopenpath
= SimpleButton(__(MSG_BTNPATH
))),
1027 Child
, (IPTR
) HVSpace
,
1028 Child
, (IPTR
) (grouptool
= (Object
*)HGroup
,
1030 Child
, (IPTR
) (groupstack
= (Object
*)HGroup
,
1032 Child
, (IPTR
) HGroup
,
1033 Child
, (IPTR
) Label2(__(MSG_COMMENT
)),
1034 Child
, (IPTR
) (commentspace
= (Object
*)StringObject
,
1040 End
, /* end hgroup information pannel */
1041 Child
, (IPTR
) HGroup
, /* hgroup protections pannel */
1042 Child
, (IPTR
) HVSpace
,
1043 Child
, (IPTR
) VGroup
,
1044 Child
, (IPTR
) HVSpace
,
1045 Child
, (IPTR
) ColGroup(4),
1046 Child
, (IPTR
) Label2(_(MSG_READ
)),
1047 Child
, (IPTR
) (readobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1048 Child
, (IPTR
) Label2(_(MSG_SCRIPT
)),
1049 Child
, (IPTR
) (scriptobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1050 Child
, (IPTR
) Label2(_(MSG_WRITE
)),
1051 Child
, (IPTR
) (writeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1052 Child
, (IPTR
) Label2(_(MSG_PURE
)),
1053 Child
, (IPTR
) (pureobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1054 Child
, (IPTR
) Label2(_(MSG_EXECUTE
)),
1055 Child
, (IPTR
) (executeobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1056 Child
, (IPTR
) Label2(_(MSG_ARCHIVED
)),
1057 Child
, (IPTR
) (archiveobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1058 Child
, (IPTR
) Label2(_(MSG_DELETE
)),
1059 Child
, (IPTR
) (deleteobject
= MUI_MakeObject(MUIO_Checkmark
,NULL
)),
1060 Child
, (IPTR
) HVSpace
,
1061 Child
, (IPTR
) HVSpace
,
1063 Child
, (IPTR
) HVSpace
,
1065 Child
, (IPTR
) HVSpace
,
1066 End
, /* end hgroup protections pannel */
1067 Child
, (IPTR
) HGroup
, /* hgroup tooltypes pannel */
1068 Child
, (IPTR
) VGroup
,
1069 Child
, (IPTR
) HGroup
,
1070 Child
, (IPTR
) VGroup
,
1073 Child
, (IPTR
) ListviewObject
,
1074 MUIA_Listview_List
, (IPTR
) (list
= ListObject
,
1076 MUIA_List_ConstructHook
, MUIV_List_ConstructHook_String
,
1077 MUIA_List_DestructHook
, MUIV_List_DestructHook_String
,
1078 MUIA_List_AutoVisible
, TRUE
,
1081 Child
, (IPTR
) (liststr
= StringObject
,
1082 MUIA_Disabled
, TRUE
,
1086 Child
, (IPTR
) HGroup
,
1088 Child
, (IPTR
) (editor
= MUI_NewObject(MUIC_TextEditor
,
1090 Child
, (IPTR
) (slider
= (Object
*)ScrollbarObject
,
1097 Child
, (IPTR
) HGroup
,
1098 MUIA_Group_SameSize
, TRUE
,
1099 Child
, (IPTR
) (newkey
= SimpleButton(__(MSG_NEW_KEY
))),
1100 Child
, (IPTR
) (delkey
= SimpleButton(__(MSG_DELETE_KEY
))),
1104 End
, /* end hgroup tooltypes pannel */
1106 Child
, (IPTR
) HGroup
,
1107 MUIA_Group_SameSize
, TRUE
,
1108 Child
, (IPTR
) (savebutton
=
1109 ImageButton(_(MSG_SAVE
),"THEME:Images/Gadgets/OK")),
1110 Child
, (IPTR
) (cancelbutton
=
1111 ImageButton(_(MSG_CANCEL
),"THEME:Images/Gadgets/Cancel")),
1119 if (application
!= NULL
)
1124 set(liststr
, MUIA_String_AttachedList
, (IPTR
)list
);
1128 DoMethod(aboutmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
1129 (IPTR
) application
, 2,
1130 MUIM_Application_ReturnID
, RETURNID_ABOUT
);
1131 DoMethod(infomenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
1132 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 0);
1133 DoMethod(protectmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
1134 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 1);
1135 DoMethod(toolmenu
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
1136 (IPTR
) registergroup
, 3, MUIM_Set
, MUIA_Group_ActivePage
, 2);
1137 DoMethod(quit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
1138 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
1139 MUIV_Application_ReturnID_Quit
);
1141 DoMethod(cancelbutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1142 (IPTR
) application
, 2,
1143 MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1144 DoMethod(savebutton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1145 (IPTR
) application
, 2,
1146 MUIM_Application_ReturnID
, RETURNID_SAVE
);
1147 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, FALSE
,
1148 (IPTR
) application
, 2,
1149 MUIM_Application_ReturnID
, RETURNID_WAKE
);
1150 DoMethod(application
, MUIM_Notify
, MUIA_Application_Sleep
, TRUE
,
1151 (IPTR
) application
, 2,
1152 MUIM_Application_ReturnID
, RETURNID_SLEEP
);
1153 DoMethod(window
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
1154 (IPTR
) application
, 2, MUIM_Application_ReturnID
,
1155 MUIV_Application_ReturnID_Quit
);
1157 DoMethod(newkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1158 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_NEWKEY
);
1159 DoMethod(delkey
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1160 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_DELKEY
);
1161 DoMethod(list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
1162 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_LVACK
);
1163 DoMethod(liststr
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
1164 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_STRINGACK
);
1166 DoMethod(commentspace
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
1167 (IPTR
) application
, 2, MUIM_Application_ReturnID
, RETURNID_COMMENTACK
);
1168 DoMethod(versionspace
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1169 (IPTR
) application
, 2,
1170 MUIM_Application_ReturnID
, RETURNID_QUERYVERSION
);
1171 DoMethod(sizespace
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1172 (IPTR
) application
, 2,
1173 MUIM_Application_ReturnID
, RETURNID_SCANSIZE
);
1174 DoMethod(readobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1175 (IPTR
) application
, 2,
1176 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1177 DoMethod(writeobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1178 (IPTR
) application
, 2,
1179 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1180 DoMethod(executeobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1181 (IPTR
) application
, 2,
1182 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1183 DoMethod(deleteobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1184 (IPTR
) application
, 2,
1185 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1186 DoMethod(scriptobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1187 (IPTR
) application
, 2,
1188 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1189 DoMethod(pureobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1190 (IPTR
) application
, 2,
1191 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1192 DoMethod(archiveobject
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
1193 (IPTR
) application
, 2,
1194 MUIM_Application_ReturnID
, RETURNID_PROTECT
);
1196 DoMethod(btnopenpath
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
1197 (IPTR
) application
, 2,
1198 MUIM_Application_ReturnID
, RETURNID_OPENPATH
);
1201 set(editor
, MUIA_TextEditor_Slider
, slider
);
1203 if (icon
->do_ToolTypes
)
1205 char *tt
= NULL
, *contents
;
1209 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
1211 len
+= strlen(icon
->do_ToolTypes
[i
]) + 1;
1215 contents
= AllocVec(len
+ 1, MEMF_ANY
);
1222 while ((icon
->do_ToolTypes
[i
]) != NULL
)
1226 strcat(contents
, "\n");
1229 strcat(contents
, icon
->do_ToolTypes
[i
]);
1234 set(editor
, MUIA_TextEditor_Contents
, contents
);
1240 if (icon
->do_ToolTypes
)
1244 while ((tt
= icon
->do_ToolTypes
[i
]) != NULL
)
1246 DoMethod(list
, MUIM_List_InsertSingle
, tt
, MUIV_List_Insert_Bottom
);
1252 switch(icon
->do_Type
)
1255 AddToolField(application
, grouptool
, deftool
);
1256 AddStackField(application
, groupstack
, stack
);
1259 AddEmptySpace(grouptool
);
1260 AddStackField(application
, groupstack
, stack
);
1263 AddEmptySpace(grouptool
);
1264 AddEmptySpace(groupstack
);
1268 if (loadedcomment
[0])
1269 nnset(commentspace
, MUIA_String_Contents
, loadedcomment
);
1271 nnset(readobject
, MUIA_Selected
, flags
[3]);
1272 nnset(writeobject
, MUIA_Selected
, flags
[4]);
1273 nnset(executeobject
, MUIA_Selected
, flags
[5]);
1274 nnset(deleteobject
, MUIA_Selected
, flags
[6]);
1276 nnset(scriptobject
, MUIA_Selected
, flags
[0]);
1277 nnset(pureobject
, MUIA_Selected
, flags
[1]);
1278 nnset(archiveobject
, MUIA_Selected
, flags
[2]);
1280 SetAttrs(window
, MUIA_Window_Open
, TRUE
, TAG_DONE
);
1282 while (returnid
!= MUIV_Application_ReturnID_Quit
)
1287 D(bug("[WBInfo] broker command received: %ld\n", returnid
));
1291 case RETURNID_SLEEP
:
1292 set(window
, MUIA_Window_Open
, FALSE
);
1293 set(window
, MUIA_Window_Activate
, TRUE
);
1296 set(window
, MUIA_Window_Open
, TRUE
);
1298 case RETURNID_ABOUT
:
1299 if (MUI_RequestA(application
, NULL
, 0,
1300 _(MSG_ABOUT
), _(MSG_OK
), _(MSG_COPYRIGHT
), NULL
))
1303 case RETURNID_NEWKEY
:
1306 case RETURNID_DELKEY
:
1308 icon_altered
= TRUE
;
1310 case RETURNID_LVACK
:
1313 case RETURNID_STRINGACK
:
1315 icon_altered
= TRUE
;
1322 SaveIcon(icon
, file
, lock
);
1324 /* This is a workardound for String.mui not sending notification on contents change */
1326 get(commentspace
, MUIA_String_Contents
, &text
);
1327 if(strcmp(loadedcomment
, text
) != 0)
1328 file_altered
= TRUE
;
1333 DoMethod(application
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
1335 case RETURNID_STACKACK
:
1336 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
1337 icon_altered
= TRUE
;
1339 case RETURNID_TOOLACK
:
1340 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
1341 icon_altered
= TRUE
;
1343 case RETURNID_COMMENTACK
:
1344 set(window
, MUIA_Window_ActiveObject
, (IPTR
)savebutton
);
1345 file_altered
= TRUE
;
1347 case RETURNID_OPENPATH
:
1348 OpenWorkbenchObject(pathname
, TAG_DONE
);
1350 case RETURNID_QUERYVERSION
:
1352 Object
* oldversionspace
= versionspace
;
1354 D(bug("[WBInfo: RETURNID_QUERYVERSION\n"));
1356 versionspace
= (Object
*)TextObject
,
1358 MUIA_Background
, MUII_TextBack
,
1359 MUIA_Text_SetMin
, FALSE
,
1360 MUIA_Text_PreParse
, (IPTR
) "\33r",
1361 MUIA_Text_Contents
, (IPTR
) GetVersion(name
, lock
),
1364 DoMethod(versiongrp
, MUIM_Group_InitChange
);
1365 DoMethod(versiongrp
, OM_REMMEMBER
, oldversionspace
);
1366 DoMethod(versiongrp
, OM_ADDMEMBER
, versionspace
);
1367 DoMethod(versiongrp
, MUIM_Group_ExitChange
);
1370 case RETURNID_SCANSIZE
:
1372 Object
* oldsizespace
= sizespace
;
1374 D(bug("[WBInfo]: RETURNID_SCANSIZE\n"));
1375 sizespace
= (Object
*)TextObject
,
1377 MUIA_Background
, MUII_TextBack
,
1378 MUIA_Text_PreParse
, (IPTR
) "\33r",
1381 DoMethod(sizegrp
, MUIM_Group_InitChange
);
1382 DoMethod(sizegrp
, OM_REMMEMBER
, oldsizespace
);
1383 DoMethod(sizegrp
, OM_ADDMEMBER
, sizespace
);
1384 DoMethod(sizegrp
, MUIM_Group_ExitChange
);
1386 if (scanStruct
== NULL
)
1387 scanStruct
= AllocMem(sizeof(struct DirScanProcess
), MEMF_CLEAR
);
1389 scanStruct
->scanState
= SCANDIE
;
1392 if (scanStruct
->scanProcess
!= NULL
)
1395 ULONG dirnamelen
= strlen(lname
) + strlen(name
);
1396 scanStruct
->scanState
= SCANRUN
;
1397 scanStruct
->scanDir
= AllocVec(dirnamelen
+ 2, MEMF_CLEAR
); /* 2 == path separator + \0 at end */
1398 D(bug("[WBInfo]: lname '%s', name '%s', (%d bytes)\n", lname
, name
, dirnamelen
));
1400 CopyMem(lname
, scanStruct
->scanDir
, strlen(lname
));
1401 AddPart(scanStruct
->scanDir
, name
, dirnamelen
+ 2);
1403 char * tmp_Name
= AllocVec(strlen(scanStruct
->scanDir
) + 24, MEMF_CLEAR
);
1404 sprintf(tmp_Name
, "Calculating size of %s ..", scanStruct
->scanDir
);
1406 /* Fire up child process to perform scan of content size .. */
1407 scanStruct
->scanProcess
= CreateNewProcTags(
1408 NP_Entry
, (IPTR
)scanDir_Process
,
1410 NP_Synchronous
, FALSE
,
1412 NP_UserData
, (IPTR
)scanStruct
,
1413 NP_StackSize
, 140960,
1419 case RETURNID_PROTECT
:
1420 file_altered
= TRUE
;
1421 D(bug("[WBInfo: Protection bits changed\n"));
1429 signals
= Wait(signals
| SIGBREAKF_CTRL_C
);
1430 if(signals
& SIGBREAKF_CTRL_C
) break;
1433 returnid
= ((LONG
) DoMethod(application
, MUIM_Application_NewInput
, (IPTR
) &signals
));
1437 scanStruct
->scanState
= SCANDIE
;
1439 if (scanStruct
->scanProcess
!= NULL
)
1442 SetAttrs(window
, MUIA_Window_Open
, FALSE
, TAG_DONE
);
1443 MUI_DisposeObject(application
);
1445 PrintFault(ERROR_INVALID_RESIDENT_LIBRARY
, argv
[0]);
1446 D(bug("[WBInfo: Couldn't create app\n"));
1447 retval
= RETURN_FAIL
;
1451 if (scanStruct
) FreeMem(scanStruct
, sizeof(struct DirScanProcess
));
1452 if (icon
) FreeDiskObject(icon
);