[comp.sys.mac.programmer] How do I stop a disk from being unmounted?

jrk@sys.uea.ac.uk (Richard Kennaway) (08/23/89)

I have a text editor which is able to edit large numbers of files
simultaneously.  To avoid running up against the absurdly small limit on
the number of files I can have open at once, it does not keep the files
open while it is editing them.  (I *know* this violates a recommendation
in some TN or other.  Ptui.)

Problem: suppose the user switches to the Finder and drags into the
trash a disk containing a file that is being edited.  The Finder will
unmount the disc.  The editor may then be unable to write the file.
Worse, if the user inserts another floppy, and the file being edited was
at the top-level of the ejected disc, then the editor will happily save
the file to the new floppy.  (As far as I can determine from
experimenting, this is because the vRefNum returned by SFGetFile for a
file in the foot folder is really an index into the list of currently
mounted volumes.)

Question: how do I stop this happening?  If a file is open on a disc,
then dragging the disc into the trash only places it offline; attempts
to write to the file will call up the "Please insert disc" dialog.  This
is the behaviour I want, but I dont want to have to keep all edited
files open.  Is there some other way of informing the Finder that a disc
is "busy" and should not be unmounted?  I didnt find anything in IM.

Strangely, having an open working directory on a disc doesnt prevent
unmounting, although it does prevent deleting a folder.

Some possible solutions occur to me, but none are really satisfactory:

1.  Remember the name of the disc, and ask for the disc if it isnt present.
No good - disc names need not be unique.

2.  Dont always close a file after reading it in, keep one open file on
each mounted volume from which any files are being edited.  Hairy.

3.  Keep open a separate empty invisible file on each volume from which
files are being edited.  I suppose this would work, but...

Isnt there some way to just tell the Finder "dont unmount this volume"?

--
Richard Kennaway          SYS, University of East Anglia, Norwich, U.K.
uucp:  ...mcvax!ukc!uea-sys!jrk		Janet:  kennaway@uk.ac.uea.sys

denbeste@bgsuvax.UUCP (William C. DenBesten) (08/24/89)

From article <695@sys.uea.ac.uk>, by jrk@sys.uea.ac.uk (Richard Kennaway):
> I have a text editor which is able to edit large numbers of files
> simultaneously.  To avoid running up against the absurdly small limit on
> the number of files I can have open at once, it does not keep the files
> open while it is editing them.  (I *know* this violates a recommendation
> in some TN or other.  Ptui.)

Keeping the files open keeps the volume from being dismounted.  It also
prevents multiple people from simultaneously editing a file on a file
server.

You can increase the number of files that can be open by editing the
boot blocks of your start up drive with Symantec Tools, MacZap, or
something similar.

-- 
William C. DenBesten   is   denbeste@bgsu.edu  or   denbesten@bgsuopie.bitnet