Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!blob From: blob@Apple.COM (Brian Bechtel) Newsgroups: comp.sys.mac.programmer Subject: Re: How to tell if a volume is a floppy drive? Message-ID: <44024@apple.Apple.COM> Date: 16 Aug 90 14:08:24 GMT References: <1517@ntmtv.UUCP> Organization: Apple Computer Inc., Cupertino, CA Lines: 50 gauthier@ntmtv.UUCP (Jay Gauthier) writes: >Hi, another simple question that I can't find an answer to in IM. >How can you tell if a vRefNum refers to a floppy disk drive? >Also, how can you tell if it is an AppleShare volume? The general >question is "How can I tell if an 'Eject' is a valid option?" The answer, from the Q&A Stack available on apple.com, is: What you probably want to know is if a device in the drive queue is removable or not. To do this, examine the four bytes of flags preceeding the drive queue entry for this device. See Inside Mac IV-181 & 182 for details. C source is: /* we assume that you get the drive number from some appropriate place, such as doing a PBHGetVInfo for the volume */ Boolean IsEjectable(driveNumber) short driveNumber { DrvQElPtr d; QHdrPtr queueHeader; Ptr p; queueHeader = GetDrvQHdr(); d = (DrvQElPtr)queueHeader->qHead; while (d != nil) /* find the appropriate drive # */ { if (d->dQDrive == driveNumber) /* is this the drive we want? */ { p = (Ptr)d; p -= 3; /* to get to the byte with eject info */ if (*p & 8) /* handles both 0x08 and 0x48 cases */ return false; /* non ejectable disk in drive */ else return true; } d = (DrvQElPtr)d->qLink; } return false; /* you specified an invalid drive number */ } Now if you really want to know if a volume is a floppy or not, use PBHGetVInfo, and multiply out the ioVNmAlBlks (remember, it's unsigned!) times ioVAlBlkSiz. Currently valid sizes include 400K, 800K, 720K, 1440K. How will you handle other sizes from the future? Nasty. That's why I think you are really asking to detect removable media. --Brian Bechtel blob@apple.com "My opinion, not Apple's"