[comp.sys.mac.programmer] raw read/write floppies

reb@cs.brown.edu (Robert E. Brown) (03/20/91)

I would like to run a program that asks the user to insert a floppy, and after
one has been inserted, reads and writes to the disk.  I have written code
that can read from a floppy disk, but inserting a floppy normally couses the
Mac to mount the disk.  How can I turn off the auto-mounting?  Once my program
has finished reading and writing the disk, how do I eject it?  At this
point, the disk is not mounted.  Will PBeject work anyway?

stevec@Apple.COM (Steve Christensen) (03/20/91)

In article <69144@brunix.UUCP> reb@cs.brown.edu (Robert E. Brown) writes:
>I would like to run a program that asks the user to insert a floppy, and after
>one has been inserted, reads and writes to the disk.  I have written code
>that can read from a floppy disk, but inserting a floppy normally couses the
>Mac to mount the disk.  How can I turn off the auto-mounting?  Once my program
>has finished reading and writing the disk, how do I eject it?  At this
>point, the disk is not mounted.  Will PBeject work anyway?

After you put up a dialog to prompt the user to insert a disk, try calling
GetOSEvent() instead of GetNextEvent().  GetNextEvent actually calls GetOSEvent
and then calls MountVol() to try to mount the disk.  After you're done you can
call PBEject() to eject the disk...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen			Never hit a man with glasses.
  stevec@apple.com			Hit him with a baseball bat.

d88-jwa@byse.nada.kth.se (Jon W{tte) (03/21/91)

In article <69144@brunix.UUCP> reb@cs.brown.edu (Robert E. Brown) writes:

   Mac to mount the disk.  How can I turn off the auto-mounting?  Once my
   program has finished reading and writing the disk, how do I eject it?
   At this point, the disk is not mounted.  Will PBeject work anyway?

You have to override using the driver to do that (the same way as
you would read an MS-DOS floppy)

But how do you propose to read/write to the floppy if you haven't
mounted it ? Normal read/write calls won't do...

What _I_ want is an utility that runs under MacOS that reads/writes
tar floppies (or cpio, or just plan _files_) to be used from A/UX.

Happy hacking,

						h+@nada.kth.se
						Jon W{tte
--
"The IM-IV file manager chapter documents zillions of calls, all of which
seem to do almost the same thing and none of which seem to do what I want
them to do."  --  Juri Munkki in comp.sys.mac.programmer

stevec@Apple.COM (Steve Christensen) (03/21/91)

d88-jwa@byse.nada.kth.se (Jon W{tte) writes:
>In article <69144@brunix.UUCP> reb@cs.brown.edu (Robert E. Brown) writes:
>
>   Mac to mount the disk.  How can I turn off the auto-mounting?  Once my
>   program has finished reading and writing the disk, how do I eject it?
>   At this point, the disk is not mounted.  Will PBeject work anyway?
>
>You have to override using the driver to do that (the same way as
>you would read an MS-DOS floppy)
>
>But how do you propose to read/write to the floppy if you haven't
>mounted it?

No.  Just because a disk isn't mounted doesn't mean you can't read or write
to it.  Drivers don't care if there's a file system around to mount a disk.
All they do is read and write blocks on the disk, which is exactly what he
wants to do.  In fact, the disk could be mounted when it's inserted, and
then his program could explicitly unmount the disk before doing the reads
and writes so he won't collide with what the file system is doing...

steve

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Steve Christensen			Never hit a man with glasses.
  stevec@apple.com			Hit him with a baseball bat.