home *** CD-ROM | disk | FTP | other *** search
- Path: comma.rhein.de!serpens!not-for-mail
- From: mlelstv@serpens.rhein.de (Michael van Elst)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Disk available?
- Date: 23 Jan 1996 14:48:43 +0100
- Organization: dis-
- Message-ID: <4e2ovr$5d3@serpens.rhein.de>
- References: <423.6596T796T2374@mailbox.swipnet.se>
- NNTP-Posting-Host: serpens.rhein.de
-
- m-29431@mailbox.swipnet.se (Daniel Adolfsson) writes:
-
- >What is the best way to find out whether there's a disk in a drive or not?
- >Just Lock()ing for example 'DF0:' won't work too good, since there might be
- >an unreadable (or a disk of another format, AFS, for example) disk in it,
- >in which case the Lock() will fail!
-
- Send the handler process an ACTION_DISKINFO. It fills out an InfoData
- structure that contains an id_DiskType. The type ID_NO_DISK_PRESENT
- is returned when there is no disk in the drive.
-
- #include <dos/dosextens.h>
- #include <proto/dos.h>
-
- BOOL dos_disk_in_drive(STRPTR devname)
- {
- struct DevProc *dvp;
- __aligned struct InfoData ID;
-
- dvp = GetDeviceProc(devname, NULL);
- if (dvp) {
- DoPkt(dvp->dvp_Port, ACTION_DISK_INFO, MKBADDR(&ID), 0, 0, 0, 0);
- FreeDeviceProc(dvp);
- return (BOOL)(ID.id_DiskType != ID_NO_DISK_PRESENT);
- }
- return FALSE;
- }
-
- void __main()
- {
- if (dos_disk_in_drive("DF0:"))
- Printf("disk inserted\n");
- else
- Printf("no disk inserted\n");
- }
-
- --
- Michael van Elst
-
- Internet: mlelstv@serpens.rhein.de
- "A potential Snark may lurk in every tree."
-