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

jmatthews@desire.wright.edu (03/21/91)

In article <D88-JWA.91Mar20172032@byse.nada.kth.se>,
  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 ? 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

I handled this under system 6.0.5 & MultiFinder by just putting my own
diskEvt handler in a standard WaitNextEvent loop. PBHGetVInfo will tell
whether the volume was mounted successfully or not. To read raw data
from a volume I use

  function BlockRead (driveNum, refNum: Integer;
                      block: LongInt; buffer: Ptr):OSErr;
    var pBlock: ParamBlockRec;
  begin
    with pBlock do
      begin
        ioVRefNum := driveNum;
        ioRefNum := refNum;
        ioBuffer := buffer;
        ioReqCount := blockSize;
        ioPosOffset := block * blockSize;
        ioPosMode := fsFromStart;
      end;
    BlockRead := PBRead(@pBlock, false)
  end;

driveNum (the drive's number) and refNum (the driver reference number)
come from walking the drive queue. (I know that's a no-no, but this IS an
unmounted volume:-) blockSize is 512 bytes and the buffer is [0..511] of
SignedByte.                                                          

If the disk is MS-DOS or ProDOS, writing an Apple File Exchange translator
might be a better way to go.

Hope this helps.

John B. Matthews