Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding all mounted volumes



On Fri, 4 Oct 2002, Eric Albert wrote:

> At 5:45 PM -0400 10/3/2002, Jason Boyd wrote:
> >How does one find all volumes/disks/whatever in a platform-agnostic way?
>
> What's a volume/disk/whatever? I'm not kidding -- on any Unix
> (including Mac OS X, I believe), you can mount drives pretty much
> anywhere in the file system, including under other mounted drives.
> At work, for example, I'll often mount a Windows drive via Samba at
> ~/windows on FreeBSD. You'd have a tough time handling that by only
> searching in certain predefined directories.

Granted I can't literally find all places where users might mount volumes,
but I can make a good guess (hopefully) at default locations. I would also
allow users to add to a path of known locations, so for instance a user
could set in preferences that their "Asset Locations" includes ~/windows.

> At the same time, as far as your data is concerned the path to a file
> always corresponds to the file's true location with the exception of
> the one case in which your data is an HFS path and your operating
> system is Mac OS X. I'm not aware of any alternative path syntax for
> Windows or Linux/Unix paths on any system (with the exception of NTFS
> Unicode paths, but I don't think you can use those in Java in the
> first place).

Actually this seems completely incorrect. The path I gave:
Foobar CD:Some Directory:subdir:file.ext

would not be a valid path on any of the above OSes, with or without the
"Foobar CD" portion (and of course translating : into a valid file
separator). Nontheless this is the legacy data I need to handle, so I need
to make all possible attempts to resolve such a path. In the case where
the user has the original CD, this would appear to be:

OS X -- "/Volumes/Foobar CD/Some Directory/subdir/file.ext"
Windows -- "<X>:/Some Directory/subdir/file.ext" (enumerating all drive
letters for X)
Linux -- "/mnt/cdrom/Some Directory/subdir/file.ext"

The point is, I can't just go with
<File.listRoots()>[/Foobar CD]/Some Directory/subdir/file.ext
because this will definitely not work most of the time on any of the
platforms.

There are not only numerous CDs possible, but end users may be storing
data on other mounted volumes.

> Given that, rather than working really hard to come up with a
> customized solution that does everything, it makes more sense to just
> special-case Mac OS X. It's trivial to convert an HFS path to a Unix
> path on Mac OS X -- you just roundtrip the path through some
> CoreFoundation CFURL functions. I posted code that does this on the
> list back in June, but it appears that the online archives are horked
> for anything before July so you can't find it there. I'll correct
> that, then, by posting the code again below. This translates from
> POSIX paths to HFS; it should be trivial for you to figure out how to
> reverse the process.
>
> Hope this helps,
> Eric

Thanks for the sample code. I'll hold on to it. However, so far I've
avoided tailoring anything to any platform and I'd still like to find
agnostic approaches in general. In this case it doesn't seem like it ought
to be so difficult to enumerate *standard mount points* if that clarifies
the disks/volumes/whatever term. It surprises me that no one has had to do
just this, or at least no one is giving a simple solution. Even Sun's
documentation and tutorials seem to have nothing relevant.

At any rate, I'll post my solution for
consideration/criticism/indifference when I figure out what approach to
use.

Thanks again.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Finding all mounted volumes (From: Eric Albert <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.