2 * Format -- disk formatting and file-system creation program
3 * Copyright (C) 1999 Ben Hutchings <womble@zzumbouk.demon.co.uk>
4 * Copyright (C) 2008 Pavel Fedin <sonic_amiga@rambler.ru>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Layout of the main window of version 40 in English is:
24 * +-------------------------------------------------------------+
25 * | Format - <device> |
26 * +-------------------------------------------------------------+
27 * | Current Information: Device '<device>' |
28 * | Volume '<volume>' |
29 * | <size> capacity <usage>% used |
30 * | _________________________________ |
31 * | New Volume Name: |Empty____________________________| |
33 * | Put Trashcan: |./| |
35 * | Fast File System: |__| |
37 * | International Mode: |__| |
39 * | Directory Cache: |__| |
41 * | +-----------------+ +-----------------+ +-----------------+ |
42 * | | Format | | Quick Format | | Cancel | |
43 * | +-----------------+ +-----------------+ +-----------------+ |
44 * +-------------------------------------------------------------+
46 * For ID_NOT_REALLY_DOS and ID_UNREADABLE_DISK volumes, the information
51 * For non-native file-systems, the lower three checkboxes are not shown.
53 * <size> is the whole number of kilobytes (units of 2^10 bytes)
54 * followed by `K', if this number is less than or equal to 9999;
55 * otherwise the whole number of megabytes (units of 2^20 bytes).
57 * The progress window has this layout:
59 * +-----------------------------------------------------------------------+
60 * | Format - <device> |
61 * +-----------------------------------------------------------------------+
63 * | Formatting disk... |
64 * | +-------------------------------------------------------------------+ |
66 * | +----------------+----------------+----------------+----------------+ |
69 * | +--------------------+ |
71 * | +--------------------+ |
72 * +-----------------------------------------------------------------------+
74 * The contents of this window are replaced by the text `Initializing
75 * disk...' for the file-system creation and trashcan creation stages.
78 #define MUIMASTER_YES_INLINE_STDARG
79 #include <libraries/mui.h>
80 #include <proto/muimaster.h>
82 #include <dos/dosextens.h>
83 #include <dos/filehandler.h>
84 #include <intuition/intuition.h>
86 #include <workbench/startup.h>
87 #include <proto/dos.h>
88 #include <proto/exec.h>
89 #include <proto/gadtools.h>
90 #include <proto/graphics.h>
91 #include <proto/intuition.h>
98 static char szCapacityInfo
[5+1+8+2+2+2+4+1];
99 static Object
*app
, *mainwin
, *formatwin
, *chk_trash
, *chk_intl
, *chk_ffs
, *chk_cache
;
100 static Object
*txt_action
, *str_volume
, *gauge
;
101 static struct DosList
* pdlVolume
= 0;
102 static struct Hook btn_format_hook
;
103 static struct Hook list_consfunc_hook
;
104 static struct Hook list_desfunc_hook
;
105 static struct Hook list_dispfunc_hook
;
107 static void message(CONST_STRPTR s
);
113 TEXT capacityInfo
[64];
116 AROS_UFH3S(IPTR
, consfunc
,
117 AROS_UFHA(struct Hook
*, h
, A0
),
118 AROS_UFHA(IPTR
*, pool
, A2
),
119 AROS_UFHA(struct SFormatEntry
*, entry
,A1
))
123 int size
= sizeof(struct SFormatEntry
);
125 struct SFormatEntry
*new = AllocPooled(pool
, size
);
127 if (new) memcpy(new, entry
, size
);
134 AROS_UFH3S(void, desfunc
,
135 AROS_UFHA(struct Hook
*, h
, A0
),
136 AROS_UFHA(IPTR
*, pool
, A2
),
137 AROS_UFHA(struct SFormatEntry
*, entry
,A1
))
141 FreePooled(pool
, entry
, sizeof(struct SFormatEntry
));
146 AROS_UFH3S(LONG
, dispfunc
,
147 AROS_UFHA(struct Hook
*, h
, A0
),
148 AROS_UFHA(char **, array
, A2
),
149 AROS_UFHA(struct SFormatEntry
*, entry
,A1
))
156 if (strlen(entry
->volumeName
))
158 strcat(s
, entry
->volumeName
);
161 strcat(s
, entry
->capacityInfo
);
164 *array
++ = entry
->deviceName
;
172 BOOL
ObjectTypeOk(struct DosList
* device
)
174 struct FileSysStartupMsg
*pfssm
;
175 struct DosEnvec
*pdenDevice
;
177 if( (pfssm
= (struct FileSysStartupMsg
*)
178 BADDR(device
->dol_misc
.dol_handler
.dol_Startup
)) == 0
179 || TypeOfMem(pfssm
) == 0
180 || pfssm
->fssm_Device
== 0
181 || (pdenDevice
= (struct DosEnvec
*)BADDR(pfssm
->fssm_Environ
)) == 0
182 || TypeOfMem(pdenDevice
) == 0
183 || pdenDevice
->de_TableSize
< DE_DOSTYPE
184 /* Check that parameters that should always be 0, are */
185 || pdenDevice
->de_SecOrg
!= 0
186 || pdenDevice
->de_Interleave
!= 0 )
188 /* error object wrong type */
192 ULLONG cbyTrack
= (ULLONG
)pdenDevice
->de_BlocksPerTrack
* (ULLONG
)(pdenDevice
->de_SizeBlock
* sizeof(LONG
));
193 ULLONG cbyCylinder
= cbyTrack
* pdenDevice
->de_Surfaces
;
195 ibyStart
= pdenDevice
->de_LowCyl
* cbyCylinder
;
196 ibyEnd
= (pdenDevice
->de_HighCyl
+ 1) * cbyCylinder
;
201 void ComputeCapacity(struct DosList
*pdlVolume
, struct InfoData
*pInfoData
)
203 /* The units of the size are initially bytes, but we shift the
204 number until the units are kilobytes, megabytes or
205 something larger and the number of units has at most 4
208 /* The unit symbols go up to exabytes, since the maximum
209 possible disk size is 2^64 bytes = 16 exabytes. */
210 const char * pchUnitSymbol
= _(MSG_UNITS
);
212 D(Printf("Calculating capacity info...\n"));
213 cUnits
= ibyEnd
- ibyStart
;
214 while( (cUnits
>>= 10) > 9999 )
217 if(pdlVolume
&& pInfoData
)
218 RawDoFmtSz( szCapacityInfo
, _(MSG_CAPACITY_USED
),
219 (ULONG
)cUnits
, (ULONG
)*pchUnitSymbol
,
220 /* Calculate percentage used, to nearest point. */
221 (ULONG
)(((ULLONG
)pInfoData
->id_NumBlocksUsed
*100ULL
222 + pInfoData
->id_NumBlocks
/2) / pInfoData
->id_NumBlocks
) );
224 RawDoFmtSz( szCapacityInfo
, "%lu%lc capacity",
225 (ULONG
)cUnits
, (ULONG
)*pchUnitSymbol
);
226 D(Printf("Done: %s\n", szCapacityInfo
));
229 void VolumesToList(Object
* listObject
)
231 ULONG flags
= LDF_READ
| LDF_DEVICES
| LDF_VOLUMES
;
232 struct DosList
*adl
, *device
, *volume
;
234 adl
= device
= AttemptLockDosList(flags
);
236 if (adl
== NULL
) return;
238 while((device
= NextDosEntry(device
, flags
- LDF_VOLUMES
)) != NULL
)
241 strcpy(name
, device
->dol_Name
);
244 /* exclude RAM, NIL, RAW, CON, ... */
245 if (!ObjectTypeOk(device
)) continue;
247 /* floppy, cdrom and unformatted disks can't be locked */
248 BPTR lock
= Lock(name
, SHARED_LOCK
);
249 BOOL addDevice
= TRUE
;
250 struct InfoData
*pInfoData
= NULL
;
254 struct InfoData infoData
;
256 /* XPIPE and PIPEFS fails here */
257 if (Info(lock
, &infoData
))
259 pInfoData
= &infoData
;
261 else addDevice
= FALSE
;
268 struct SFormatEntry entry
;
269 strcpy(entry
.deviceName
, device
->dol_Name
);
274 if ((volume
= NextDosEntry(volume
, LDF_VOLUMES
)) == 0) break;
275 } while((volume
->dol_Ext
.dol_AROS
.dol_Device
!= device
->dol_Ext
.dol_AROS
.dol_Device
) ||
276 (volume
->dol_Ext
.dol_AROS
.dol_Unit
!= device
->dol_Ext
.dol_AROS
.dol_Unit
));
278 if (volume
) strcpy(entry
.volumeName
, volume
->dol_Name
);
279 else strcpy(entry
.volumeName
, "");
281 ComputeCapacity(volume
, pInfoData
);
282 strcpy(entry
.capacityInfo
, szCapacityInfo
);
284 DoMethod(listObject
, MUIM_List_InsertSingle
, &entry
,
285 MUIV_List_Insert_Top
);
289 UnLockDosList(flags
);
292 struct SFormatEntry
* SelectDevice(void)
294 Object
*app
, *wnd
, *list
, *ok
, *cancel
;
296 list_consfunc_hook
.h_Entry
= (HOOKFUNC
)consfunc
;
297 list_desfunc_hook
.h_Entry
= (HOOKFUNC
)desfunc
;
298 list_dispfunc_hook
.h_Entry
= (HOOKFUNC
)dispfunc
;
300 app
= (Object
*)ApplicationObject
,
301 SubWindow
, (IPTR
)(wnd
= (Object
*)WindowObject
,
302 MUIA_Window_CloseGadget
, (IPTR
)FALSE
,
303 MUIA_Window_Title
, (IPTR
)_(MSG_APPLICATION_TITLE
),
304 WindowContents
, (IPTR
)(VGroup
,
305 Child
, (IPTR
)(TextObject
,
306 MUIA_Text_Contents
, (IPTR
)_(MSG_SELECTDEVICE
),
308 Child
, (IPTR
)(list
= (Object
*)ListviewObject
,
309 MUIA_Listview_List
, ListObject
,
311 MUIA_List_ConstructHook
, (IPTR
)&list_consfunc_hook
,
312 MUIA_List_DestructHook
, (IPTR
)&list_desfunc_hook
,
313 MUIA_List_DisplayHook
, (IPTR
)&list_dispfunc_hook
,
314 MUIA_List_Format
, (IPTR
)",",
315 MUIA_List_AdjustWidth
, (IPTR
)TRUE
,
318 Child
, (IPTR
)(HGroup
,
319 Child
, (IPTR
)(ok
= SimpleButton(_(MSG_OK
))),
320 Child
, (IPTR
)RectangleObject
, End
,
321 Child
, (IPTR
)(cancel
= SimpleButton(_(MSG_CANCEL
))),
327 if(app
== NULL
) return NULL
;
331 DoMethod(list
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
332 ok
, 3, MUIM_Set
, MUIA_Disabled
, FALSE
);
333 DoMethod(ok
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
334 app
, 2, MUIM_Application_ReturnID
, (IPTR
)ok
);
335 DoMethod(cancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
336 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
338 set(ok
, MUIA_Disabled
, TRUE
);
339 set(wnd
, MUIA_Window_Open
, TRUE
);
344 struct SFormatEntry
* selectedEntry
= NULL
;
346 while((returnId
= (LONG
)DoMethod(app
, MUIM_Application_NewInput
, (IPTR
)&sigs
))
347 != MUIV_Application_ReturnID_Quit
)
351 if ((Object
*) returnId
== ok
)
353 IPTR active
= XGET(list
, MUIA_List_Active
);
354 struct SFormatEntry
*entry
;
355 DoMethod(list
, MUIM_List_GetEntry
, active
, &entry
);
356 selectedEntry
= AllocMem(sizeof(struct SFormatEntry
), 0L);
358 memcpy(selectedEntry
, entry
, sizeof(struct SFormatEntry
));
362 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
364 if (sigs
& SIGBREAKF_CTRL_C
)
369 MUI_DisposeObject(app
);
371 return selectedEntry
;
374 AROS_UFH3S(void, btn_format_function
,
375 AROS_UFHA(struct Hook
*, h
, A0
),
376 AROS_UFHA(Object
*, object
, A2
),
377 AROS_UFHA(IPTR
*, msg
, A1
))
381 BOOL bDoFormat
= *msg
;
382 BOOL bMakeTrashcan
, bFFS
, bIntl
;
383 BOOL bDirCache
= FALSE
;
386 D(Printf("Full format? %d\n", bDoFormat
));
388 if(!bSetSzDosDeviceFromSz(szDosDevice
))
391 /* TODO: set volume name same as old one if name is null string */
392 if( !bSetSzVolumeFromSz( (char *)XGET(str_volume
, MUIA_String_Contents
) ) )
397 bMakeTrashcan
= XGET(chk_trash
, MUIA_Selected
);
398 bFFS
= XGET(chk_ffs
, MUIA_Selected
);
399 bIntl
= XGET(chk_intl
, MUIA_Selected
);
400 bDirCache
= XGET(chk_cache
, MUIA_Selected
);
407 set(txt_action
, MUIA_Text_Contents
, _(MSG_GUI_FORMATTING
) );
411 set(txt_action
, MUIA_Text_Contents
, _(MSG_GUI_INITIALIZING
) );
414 set(mainwin
, MUIA_Window_Open
, FALSE
);
415 set(formatwin
, MUIA_Window_Open
, TRUE
);
418 char szVolumeId
[11 + MAX_FS_NAME_LEN
];
420 RawDoFmtSz( szVolumeId
, "%b", pdlVolume
->dol_Name
);
422 RawDoFmtSz( szVolumeId
, _(MSG_IN_DEVICE
), szDosDevice
);
423 if( MUI_Request ( app
, formatwin
, 0,
424 _(MSG_FORMAT_REQUEST_TITLE
), _(MSG_FORMAT_REQUEST_GADGETS
),
425 _(MSG_FORMAT_REQUEST_TEXT
),
426 szVolumeId
, szCapacityInfo
) != 1)
430 BOOL formatOk
= TRUE
;
434 if(!bGetExecDevice(TRUE
))
436 D(PutStr("GetExecDevice done\n"));
437 set(gauge
, MUIA_Gauge_Max
, HighCyl
-LowCyl
);
438 for( icyl
= LowCyl
; icyl
<= HighCyl
; ++icyl
)
440 DoMethod(app
, MUIM_Application_Input
, (IPTR
)&sigs
);
441 /* interrupted by user? */
442 if(XGET(formatwin
, MUIA_UserData
) == 1)
447 if(!bFormatCylinder(icyl
) || !bVerifyCylinder(icyl
))
452 set(gauge
, MUIA_Gauge_Current
, icyl
-LowCyl
);
455 D(PutStr("FreeExecDevice done\n"));
459 if( bMakeFileSys( bFFS
, !bFFS
, bIntl
, !bIntl
, bDirCache
, !bDirCache
)
460 && (!bMakeTrashcan
|| bMakeFiles(FALSE
)) )
464 DoMethod(app
, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
471 static char szTitle
[6+3+30+1];
472 char szVolumeInfo
[6+2+MAX_FS_NAME_LEN
+2];
473 char szDeviceInfo
[6+2+MAX_FS_NAME_LEN
+2];
474 char szVolumeName
[108];
475 struct DosList
*pdlDevice
= NULL
;
476 szVolumeInfo
[0] = '\0';
477 #ifdef AROS_FAKE_LOCK
480 struct FileLock
* pflVolume
= 0;
482 static struct InfoData dinf
__attribute__((aligned (4)));
483 LONG rc
= RETURN_FAIL
;
487 Open("CON:0/50/640/400/Format Debug Output/CLOSE/WAIT",MODE_READWRITE
);
488 BPTR OldInput
= SelectInput(bpfhStdErr
);
489 BPTR OldOutput
= SelectOutput(bpfhStdErr
);
492 if( _WBenchMsg
->sm_NumArgs
> 1 )
494 struct DosList
*pdlList
;
496 if( _WBenchMsg
->sm_ArgList
[1].wa_Lock
== 0 )
498 D(Printf("Object specified by name: %s\n", _WBenchMsg
->sm_ArgList
[1].wa_Name
);)
500 if( !bSetSzDosDeviceFromSz(_WBenchMsg
->sm_ArgList
[1].wa_Name
) ) {
501 D(Printf("Bad device name wrom Workbench: %s\n", _WBenchMsg
->sm_ArgList
[1].wa_Name
));
502 /* Workbench is playing silly buggers */
506 else if( _WBenchMsg
->sm_ArgList
[1].wa_Name
[0] == 0 )
510 D(Printf("Object specified by lock\n"));
511 /* make sure it's mounted before looking for its device */
512 if( !Info( _WBenchMsg
->sm_ArgList
[1].wa_Lock
, &dinf
) )
514 ReportErrSz( ertFailure
, 0, 0 );
517 #ifdef AROS_FAKE_LOCK
518 if (NameFromLock(_WBenchMsg
->sm_ArgList
[1].wa_Lock
, volName
, sizeof(volName
)))
520 D(Printf("Volume name: %s\n", volName
));
521 volName
[strlen(volName
)-1] = '\0';
522 pdlList
= LockDosList( LDF_DEVICES
| LDF_VOLUMES
| LDF_READ
);
523 pdlVolume
= FindDosEntry(pdlList
, volName
, LDF_VOLUMES
);
526 D(Printf("Looking for device = 0x%08lX Unit = 0x%08lX\n",
527 pdlVolume
->dol_Ext
.dol_AROS
.dol_Device
,
528 pdlVolume
->dol_Ext
.dol_AROS
.dol_Unit
));
532 if ((pdlDevice
= NextDosEntry(pdlDevice
, LDF_DEVICES
)) == 0)
534 D(Printf("Checking device %s:\n", pdlDevice
->dol_Ext
.dol_AROS
.dol_DevName
);)
535 D(Printf("Device = 0x%08lX Unit = 0x%08lX\n", pdlDevice
->dol_Ext
.dol_AROS
.dol_Device
,
536 pdlDevice
->dol_Ext
.dol_AROS
.dol_Unit
);)
538 while((pdlDevice
->dol_Ext
.dol_AROS
.dol_Device
!= pdlVolume
->dol_Ext
.dol_AROS
.dol_Device
) ||
539 (pdlDevice
->dol_Ext
.dol_AROS
.dol_Unit
!= pdlVolume
->dol_Ext
.dol_AROS
.dol_Unit
));
544 (struct FileLock
*)BADDR(_WBenchMsg
->sm_ArgList
[1].wa_Lock
);
545 pdlVolume
= (struct DosList
*)BADDR(pflVolume
->fl_Volume
);
546 pdlList
= LockDosList( LDF_DEVICES
| LDF_READ
);
550 if ((pdlDevice
= NextDosEntry(pdlDevice
, LDF_DEVICES
)) == 0)
553 while( pdlDevice
->dol_Task
!= pflVolume
->fl_Task
);
557 ReportErrSz( ertFailure
, ERROR_DEVICE_NOT_MOUNTED
, 0 );
560 RawDoFmtSz( szDosDevice
, "%b", pdlDevice
->dol_Name
);
561 pchDosDeviceColon
= szDosDevice
+ strlen(szDosDevice
);
562 *(pchDosDeviceColon
+1) = 0;
566 ReportErrSz( ertFailure
, ERROR_OBJECT_WRONG_TYPE
, 0 );
570 ComputeCapacity(pdlVolume
, &dinf
);
573 strcpy(szVolumeName
, pdlVolume
->dol_Name
);
575 else if ( _WBenchMsg
->sm_NumArgs
== 1 )
577 /* message(_(MSG_ERROR_WANDERER) ); */
578 struct SFormatEntry
* entry
= SelectDevice();
581 strcpy(szDosDevice
, entry
->deviceName
);
582 strcat(szDosDevice
, ":");
583 strcpy(szVolumeName
, entry
->volumeName
);
584 strcpy(szCapacityInfo
, entry
->capacityInfo
);
585 FreeMem(entry
, sizeof(struct SFormatEntry
));
587 D(Printf("Object name selected via SelectDevice: %s\n", szDosDevice
));
589 if( !bSetSzDosDeviceFromSz(szDosDevice
) ) {
590 D(Printf("Bad device name from SelectDevice: %s\n", szDosDevice
));
595 #ifdef AROS_FAKE_LOCK
596 if (!bGetDosDevice(pdlDevice
, LDF_DEVICES
|LDF_VOLUMES
|LDF_READ
))
598 if (!bGetDosDevice(pdlDevice
, LDF_DEVICES
|LDF_READ
))
602 RawDoFmtSz( szTitle
, _(MSG_WINDOW_TITLE
), szDosDevice
);
603 D(Printf("Setting window title to '%s'\n", szTitle
));
606 Object
*btn_format
, *btn_qformat
, *btn_cancel
, *btn_stop
;
608 btn_format_hook
.h_Entry
= (HOOKFUNC
)btn_format_function
;
610 RawDoFmtSz( szDeviceInfo
, _(MSG_DEVICE
), szDosDevice
);
611 RawDoFmtSz( szVolumeInfo
, _(MSG_VOLUME
), szVolumeName
);
613 D(Printf("Creating GUI...\n"));
615 app
= (Object
*)ApplicationObject
,
616 MUIA_Application_Title
, __(MSG_APPLICATION_TITLE
),
617 MUIA_Application_Version
, (IPTR
)szVersion
,
618 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
619 MUIA_Application_Copyright
, __(MSG_COPYRIGHT
),
620 MUIA_Application_Author
, __(MSG_AUTHOR
),
621 MUIA_Application_Base
, (IPTR
)"FORMAT",
622 MUIA_Application_SingleTask
, FALSE
,
623 SubWindow
, (IPTR
)(mainwin
= (Object
*)WindowObject
,
624 MUIA_Window_ID
, MAKE_ID('F','R','M','1'),
625 MUIA_Window_Title
, (IPTR
)szTitle
,
626 WindowContents
, (IPTR
)(VGroup
,
627 Child
, (IPTR
)(ColGroup(2),
628 Child
, (IPTR
)Label2( _(MSG_LABEL_CURRENT_INFORMATION
) ),
629 Child
, (IPTR
)(TextObject
,
631 MUIA_Text_Contents
, (IPTR
)szDeviceInfo
,
633 Child
, (IPTR
)Label2(""),
634 Child
, (IPTR
)(TextObject
,
636 MUIA_Text_Contents
, (IPTR
)szVolumeInfo
,
638 Child
, (IPTR
)Label2(""),
639 Child
, (IPTR
)(TextObject
,
641 MUIA_Text_Contents
, (IPTR
)szCapacityInfo
,
643 Child
, (IPTR
)Label2( _(MSG_LABEL_NEW_VOLUME_NAME
) ),
644 Child
, (IPTR
)(str_volume
= (Object
*)StringObject
,
646 MUIA_String_Contents
, __(MSG_DEFAULT_VOLUME_NAME
),
647 MUIA_String_MaxLen
, MAX_FS_NAME_LEN
,
649 Child
, (IPTR
)Label2( _(MSG_LABEL_PUT_TRASHCAN
) ),
650 Child
, (IPTR
)(chk_trash
= MUI_MakeObject(MUIO_Checkmark
, NULL
)),
651 Child
, (IPTR
)Label2( _(MSG_LABEL_FFS
) ),
652 Child
, (IPTR
)(chk_ffs
= MUI_MakeObject(MUIO_Checkmark
, NULL
)),
653 Child
, (IPTR
)Label2( _(MSG_LABEL_INTL
)),
654 Child
, (IPTR
)(chk_intl
= MUI_MakeObject(MUIO_Checkmark
, NULL
)),
655 Child
, (IPTR
)Label2( _(MSG_LABEL_CACHE
) ),
656 Child
, (IPTR
)(chk_cache
= MUI_MakeObject(MUIO_Checkmark
, NULL
)),
658 Child
, (IPTR
) (RectangleObject
,
659 MUIA_Rectangle_HBar
, TRUE
,
662 Child
, (IPTR
)(HGroup
,
663 Child
, (IPTR
)(btn_format
= ImageButton( _(MSG_BTN_FORMAT
) , "THEME:Images/Gadgets/Prefs/Save")),
664 Child
, (IPTR
)(btn_qformat
= ImageButton( _(MSG_BTN_QFORMAT
), "THEME:Images/Gadgets/Prefs/Save")),
665 Child
, (IPTR
)(btn_cancel
= ImageButton( _(MSG_BTN_CANCEL
) , "THEME:Images/Gadgets/Prefs/Cancel")),
669 SubWindow
, (IPTR
)(formatwin
= (Object
*)WindowObject
,
670 MUIA_Window_ID
, MAKE_ID('F','R','M','2'),
671 MUIA_Window_Title
, (IPTR
)szTitle
,
672 MUIA_Window_CloseGadget
, (IPTR
)FALSE
,
673 WindowContents
, (IPTR
)(VGroup
,
674 Child
, (IPTR
)(txt_action
= (Object
*)TextObject
,
677 Child
, (IPTR
)(gauge
= (Object
*)GaugeObject
,
679 MUIA_Gauge_Horiz
, (IPTR
)TRUE
,
680 MUIA_FixHeightTxt
, (IPTR
)"|",
682 Child
, (IPTR
)(HGroup
,
683 Child
, RectangleObject
, End
,
684 Child
, (IPTR
)(btn_stop
= SimpleButton( _(MSG_BTN_STOP
) )),
685 Child
, RectangleObject
, End
,
689 End
; /* Application */
693 message( _(MSG_ERROR_NO_APPLICATION
) );
697 DoMethod(mainwin
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
698 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
699 DoMethod(btn_cancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
700 app
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
701 DoMethod(btn_format
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
702 app
, 3, MUIM_CallHook
, (IPTR
)&btn_format_hook
, TRUE
);
703 DoMethod(btn_qformat
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
704 app
, 3, MUIM_CallHook
, (IPTR
)&btn_format_hook
, FALSE
);
705 DoMethod(btn_stop
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
706 formatwin
, 3, MUIM_Set
, MUIA_UserData
, 1);
708 set(chk_trash
, MUIA_Selected
, TRUE
);
709 if( DosType
>= 0x444F5300 && DosType
<= 0x444F5305 )
711 set(chk_ffs
, MUIA_Selected
, DosType
& 1UL);
712 set(chk_intl
, MUIA_Selected
, DosType
& 6UL);
713 set(chk_cache
, MUIA_Selected
, DosType
& 4UL);
717 set(chk_ffs
, MUIA_Disabled
, TRUE
);
718 set(chk_intl
, MUIA_Disabled
, TRUE
);
719 set(chk_cache
, MUIA_Disabled
, TRUE
);
722 set(chk_cache
, MUIA_Disabled
, TRUE
);
724 set(mainwin
, MUIA_Window_Open
, TRUE
);
726 if (! XGET(mainwin
, MUIA_Window_Open
))
728 message( _(MSG_ERROR_NO_WINDOW
) );
731 DoMethod(app
, MUIM_Application_Execute
);
736 MUI_DisposeObject(app
);
739 SelectInput(OldInput
);
740 SelectOutput(OldOutput
);
747 static void message(CONST_STRPTR s
)
752 MUI_Request(app
, NULL
, 0, _(MSG_REQ_ERROR_TITLE
), _(MSG_OK
), s
);