Re: Volume Tracking in Cocoa without Carbon?
Re: Volume Tracking in Cocoa without Carbon?
- Subject: Re: Volume Tracking in Cocoa without Carbon?
- From: Deirdre Saoirse Moen <email@hidden>
- Date: Mon, 14 May 2001 14:09:41 -0700
I'm looking for a method to get a list of mounted volumes (and
theoretically their icons). At the same time I am looking for
something like system even messages for disk mount and disk eject. I
know where these were in the Mac OS APIs and thus know where I could
look for them in Carbon. However, my goal is to work these into a
Cocoa (obj-c) only app through Project Builder and have had no luck
finding NSObjects or the appropriate framework through header files
or documentation.
The problem is that the paradigm you're looking for isn't there: it's
simply not the same beast.
In Unix, the root volume is mounted at / and all other volumes are
mounted at some point under that -- in a typical Unix, where a
directory already exists. I suspect, but can't confirm, that the
volumes one mounts when adding/subtracting volumes are directories
created and/or deleted on the fly.
On other unixes, this is specified in /etc/fstab and the current
mount state is in /etc/mtab -- but these files aren't used that way
on MacOS X. For example, my Linux box has the following mount points:
/dev/sda1 / ext2 defaults,errors=remount-ro 0 1
/dev/sda2 /var ext2 rw 0 2
/dev/sda3 /usr ext2 rw 0 2
/dev/sda6 /home ext2 rw 0 2
/dev/sda7 /cvs ext2 rw 0 2
/dev/sda8 /www ext2 rw 0 2
/dev/sda9 /usr/local ext2 rw 0 2
/dev/sda10 /var/spool/news ext2 rw 0 2
/dev/sda11 /var/lib/mysql ext2 rw 0 2
Now, suppose I *did* have a /var/spool/news on MacOS X and it had a
volume mounted there. Do you care about that?
The default behavior on MacOS X is to add other volumes by name in
/Volumes, but there's no real guarantee that someone didn't just
create a directory there. And there's no requirement that that's
where the directory be mounted.
I'm not saying it's an insoluable problem, I'm just wondering: why is
it important? For example, if I mount a paritition at the mount point
where my web server documents are, I'm not likely to want you to muck
with it, right?
In other words, I think you'd be OK just assuming that volumes of
interest would be found in /Volumes.
--
_Deirdre Stash-o-Matic:
http://weirdre.com http://deirdre.net
Macintosh Developer (seeking work): Will work for Cocoa
"I love deadlines. I like the whooshing sound they make as they fly by."
- Douglas Adams