Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 5 - Disk Initialization Manager / Disk Initialization Manager Reference
Routines / Initializing a Disk


DIBadMount

To respond to the user's insertion of an uninitialized or damaged disk, you can call the DIBadMount function.

FUNCTION DIBadMount (where: Point; evtMessage: LongInt): Integer;
where
The desired location, in global coordinates, of the upper-left corner of the disk initialization dialog box. In system software versions 7.0 and later, this parameter is ignored, and the dialog box is automatically centered on the screen.
evtMessage
The event message received when the disk is inserted. The high word of this message contains the result code associated with the disk insertion. The low word of this message indicates the number of the drive into which the user inserted the disk.
DESCRIPTION
The DIBadMount function evaluates the result code in the high word of the evtMessage parameter and responds appropriately. If the result code is noErr, the function allows
the user to erase the contents of the disk. If the result code is ioErr, badMDBErr, or noMacDskErr, initializing the disk might correct the problem, and so DIBadMount displays a dialog box that explains the problem and allows the user to initialize the disk. If the result code is extFSErr, memFullErr, nsDrvErr, paramErr, or volOnLinErr, then initializing the disk would not correct the problem. In this case, DIBadMount ejects the disk from the drive and returns the result code.

Before presenting the disk initialization dialog box, DIBadMount checks whether the drive contains an already mounted volume. If so, it ejects the disk and returns 2 as its result. This happens rarely and could reflect an error in your application (for example, you forgot to call DILoad, and the user had to switch to the disk containing the System resource file).

The DIBadMount function uses just one disk initialization dialog box to cover all disk initialization situations. The dialog box contains many dialog items, which are hidden and shown as appropriate. The dialog box always contains an icon indicating the drive containing the disk to be initialized.

The initial text of the disk initialization dialog box depends on the result code received. For example, if you pass noMacDskErr to DIBadMount in the evtMessage parameter, the dialog box displays the text "This is not a Macintosh disk." If you pass the result
code noErr, you can customize the message by using the Dialog Manager's ParamText procedure.

The disk initialization dialog box contains a button allowing the user to cancel the initialization and one or two buttons allowing the user to request initialization of
the disk. Usually, the cancel button is labeled Eject, but if the result code passed to DIBadMount within the evtMessage parameter is noErr, then the cancel button is labeled Cancel. If the user responds to the disk initialization dialog box by clicking
the Eject button, DIBadMount ejects the disk and returns 1 as its result. If the user
clicks the Cancel button, DIBadMount returns 1 but does not eject the disk.

In most cases, the Initialize button is the only alternative to the Eject or Cancel button. However, if the user inserts a double-sided (but not high-density) disk into a double-sided or high-density disk drive, DIBadMount presents buttons labeled One-Sided and Two-Sided. The user can then decide whether to make the disk single-sided or double-sided. If the user clicks the Initialize button, the One-Sided button, or the Two-Sided button, DIBadMount warns the user that the initialization process erases any existing data on the disks. If the user proceeds, DIBadMount allows the user to name the disk if it is not already named and then updates the text of the dialog box to inform the user of the progress of the operation. If the operation fails, DIBadMount alerts the user and ejects the disk, returning an appropriate result code.

You can use DIBadMount to format hard disks as well as floppy disks. However, you should not attempt to format the startup volume.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for DIBadMount are
Trap macroSelector
_Pack2$0000

SPECIAL CONSIDERATIONS
Because the DIBadMount function might allocate memory, you should not call it at interrupt time.

RESULT CODES
[no name]2Disk in specified drive is already mounted
[no name]1User canceled initializing
noErr0No error
paramErr-50Drive number specified is bad
volOnLinErr-55Volume is already online
nsDrvErr-56No such drive
extFSErr-58Disk has external file system
lastDskErr-64Last of the range of low-level disk errors
...  
firstDskErr-84First of the range of low-level disk errors
memFullErr-108Not enough memory

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996