Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!mcsun!ukc!sys.uea!jrk From: jrk@sys.uea.ac.uk (Richard Kennaway) Newsgroups: comp.sys.mac.programmer Subject: How do I stop a disk from being unmounted? Message-ID: <695@sys.uea.ac.uk> Date: 23 Aug 89 16:00:50 GMT Reply-To: jrk@uea-sys.UUCP (Richard Kennaway) Organization: University of East Anglia, Norwich Lines: 42 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