The File System: 3.1 Disks and Drives: Accessing Drives

Up: GEOS SDK TechDocs | Up | Prev: 3 Disks and Drives | Next: 3.2 Accessing Disks
DriveGetStatus(), DriveGetExtStatus(), DriveGetDefaultMedia(), DriveTestMediaSupport(), DriveGetName(), DriveStatus, DriveType, MediaType

Most systems running GEOS have access to a number of different drives. With the exception of network drives, the drives available will usually not change during an execution of GEOS, although the volumes mounted on the drives can change. Every drive is accessed by its drive number . This token is a byte-length integer value.

When you wish to open a file, you must specify its volume, not its drive. This is because the volume mounted on a drive can change frequently and without warning.

GEOS provides routines to get information about a drive. To get general information about a drive, call the routine DriveGetStatus() . This routine takes the drive number and returns a word-length set of DriveStatus flags (defined in drive.h ). If an error condition exists, such as the drive you request not existing, it returns zero. The following flags may be returned:

DS_PRESENT
This flag is set if the physical drive exists, regardless of whether the drive contains a disk.
DS_MEDIA_REMOVABLE
This flag is set if the disk can be removed from the drive.
DS_NETWORK
This flag is set if the drive is accessed over a network (or via network protocols), which means the drive cannot be formatted or copied.
DS_TYPE
This is a mask for the lowest four bits of the field. These bits contain a member of the DriveType enumerated type.

The lowest four bits of the word contains a member of the DriveType enumerated type. The field can be accessed by masking out all the bits except for those set in DS_TYPE. DriveType comprises the following values:

DRIVE_5_25
Drive uses 5.25-inch floppy disks.
DRIVE_3_5
Drive uses 3.5-inch floppy disks.
DRIVE_FIXED
Drive uses some kind of fixed disk (e.g. a hard drive).
DRIVE_RAM
Drive is chip-based (either RAM or ROM).
DRIVE_CD_ROM
Drive uses read-only optical disks.
DRIVE_8
Drive uses 8-inch floppy disks.
DRIVE_UNKNOWN
Drive type is unknown.

DriveGetStatus() returns the information most often needed about a drive. However, you may sometimes need more obscure information. For this reason, GEOS provides the routine DriveGetExtStatus() . Like DriveGetStatus() , it takes the drive number as an argument and returns a word of flags; however, it returns additional flags. The flags returned by DriveGetStatus() are set in the lower byte of the returned word; special additional flags are set in the upper byte. Like DriveGetStatus() , DriveGetExtStatus() returns zero if the drive specified is invalid. The following flags are defined for the upper byte:

DES_LOCAL_ONLY
This flag is set if the device cannot be viewed over a network.
DES_READ_ONLY
This flag is set if the device is read only, i.e. no data can ever be written to a volume mounted on it (e.g., a CD-ROM drive).
DES_FORMATTABLE
This flag is set if disks can be formatted in the drive.
DES_ALIAS
This flag is set if the drive is actually an alias for a path on another drive.
DES_BUSY
This flag is set if the drive will be busy for an extended period of time (e.g., if a disk is being formatted).

Many disk drives can take a variety of disks. For example, high-density 3.5-inch drives can read and write to either 720K disks or 1.44M disks. Every drive has a "default" media type. When you format a disk in that drive, it will, by default, be formatted to the default size. To find out the default disk type, call the routine DriveGetDefaultMedia() . This routine takes one argument, namely the drive number. It returns a member of the MediaType enumerated type. MediaType has the following possible values:

MEDIA_160K, MEDIA_180K, MEDIA_320K, MEDIA_360K
These are all sizes used by 5.25-inch disks.
MEDIA_720K
This is the size of a regular 3.5-inch disk.
MEDIA_1M2
This is the size of a high-density 5.25-inch disk.
MEDIA_1M44
This is the size of a high-density 3.5-inch disk.
MEDIA_2M88
This is the size of an ultra-high-density 3.5-inch disk.
MEDIA_FIXED_DISK
This is returned for all fixed disks.
MEDIA_CUSTOM
This is returned if none of the other values is appropriate. For example, it is returned for CD-ROM drives.
MEDIA_NONEXISTENT
This is returned if the drive specified does not contain a disk. This value is defined to be equal to zero.

If you want to find out if a drive can accommodate a certain kind of disk, call the routine DriveTestMediaSupport() . This Boolean routine takes two arguments: a drive number and a member of the MediaType enumerated type. If the drive supports that medium, the routine returns true (i.e. non-zero); otherwise, it returns false (i.e. zero).

To find out the name of a given drive, call DriveGetName() . This routine is passed three arguments: a drive number, a pointer to a character buffer, and the size of that buffer. DriveGetName() writes the drive's name to the buffer as a null-terminated string; it returns a pointer to that trailing null. If the buffer was not large enough, or the drive does not exist, it returns a null pointer.


Up: GEOS SDK TechDocs | Up | Prev: 3 Disks and Drives | Next: 3.2 Accessing Disks