Up: GEOS SDK TechDocs| Up | Prev: DiskCheckInUse() ... | Next: DiskGetDrive() ...

DiskForEach()

DiskHandle 	DiskForEach(
        Boolean _pascal (* callback)			(DiskHandle				disk)) 		/* callback returns true
									 * to cancel */

This routine lets you perform an action on every registered disk. It calls the callback routine once for each disk, passing the disk's handle. The callback routine must be declared _pascal. The callback routine can force an early termination by returning true (i.e. non-zero). If the callback routine ever returns true , DiskForEach() terminates and returns the handle of the last disk passed to the callback routine. If the callback routine examines every disk without returning true , DiskForEach() returns a null handle.

Tips and Tricks: DiskForEach() is commonly used to look for a specific disk. The callback routine checks each disk to see if it's the one; if it finds a match, the callback routine simply returns true , and DiskForEach() returns the disk's handle.

Include: disk.h

DiskFormat()

FormatError 	DiskFormat(
        word 		driveNumber,
        MediaType	media,			/* Format to this size */
        DiskFormatFlags	flags,			/* See flags below */
        dword		*goodClusters,		/* These are filled in at the */
        dword		*badClusters,		/* of the format */
	DiskHandle 	disk,			/* handle of disk, or
						 * 0 if disk unformatted, or
						 * 1 if drive state unknown */
	char 		*volumeName,		/* new name of disk */
        Boolean _pascal (*callback)		
			(word percentDone));	/* Return true to cancel */

This routine formats a disk to the specified size. When it is finished, it fills in the passed pointers to contain the number of good and bad clusters on the disk. (To find out the size of each cluster, call DiskGetVolumeInfo().) The routine returns a member of the FormatError enumerated type (whose members are described below).

DiskFormat() can be instructed to call a callback routine periodically. This allows the application to keep the user informed about how the format is progressing. The callback routine is passed either the percent of the disk which has been formatted, or the cylinder and head currently being formatted. The callback routine must be declared _pascal. The callback routine can cancel the format by returning true (i.e. non-zero); otherwise, it should return false (i.e. zero).

The third argument passed is a word-length flag field. Currently, only three flags are defined:

DFF_CALLBACK_PERCENT_DONE
A callback routine should be called periodically. The callback routine should be passed a single argument, namely the percentage of the format which has been done.
DFF_CALLBACK_CYL_HEAD
A callback routine should be called periodically. The callback routine should be passed a single argument, namely the cylinder head being formatted. If both DFF_CALLBACK_PERCENT_DONE and DFF_CALLBACK_CYL_HEAD are passed, results are undefined. If neither flag is set, the callback routine will never be called; a null function pointer may be passed.
DFF_FORCE_ERASE
A "hard format" should be done, i.e. the sectors should be rewritten and initialized to zeros. If this flag is not set, DiskFormat() will do a "soft format" if possible; it will check the sectors and write a blank file allocation table, but it will not necessarily erase the data from the disk.

DiskFormat() returns a member of the FormatError enumerated type. If the format was successful, it will return the constant FMT_DONE (which is guaranteed to equal zero). Otherwise, it will return one of the following constants:

FMT_DRIVE_NOT_READY
FMT_ERROR_WRITING_BOOT
FMT_ERROR_WRITING_ROOT_DIR
FMT_ERROR_WRITING_FAT
FMT_ABORTED
FMT_SET_VOLUME_NAME_ERROR
FMT_CANNOT_FORMAT_FIXED_DISKS_IN_CUR_RELEASE
FMT_BAD_PARTITION_TABLE
FMT_ERR_NO_PARTITION_FOUND
FMT_ERR_CANNOT_ALLOC_SECTOR_BUFFER
FMT_ERR_DISK_IS_IN_USE
FMT_ERR_WRITE_PROTECTED
FMT_ERR_DRIVE_CANNOT_SUPPORT_GIVEN_FORMAT
FMT_ERR_INVALID_DRIVE_SPECIFIED
FMT_ERR_DRIVE_CANNOT_BE_FORMATTED
FMT_ERR_DISK_UNAVAILABLE

Include: disk.h


Up: GEOS SDK TechDocs| Up | Prev: DiskCheckInUse() ... | Next: DiskGetDrive() ...