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



Jason Boyd <email@hidden> wrote:

>[...] Our legacy data contains file paths
>which include the volume name and use old Mac syntax like so:
>
>Foobar CD:Some Directory:subdir:file.ext
>
>Now I need to manipulate these paths to find the actual file but it must
>work on OS X, Windows 98 and later, and Linux/UNIX.

How do you propose to map a Mac-specific volume-name (Foobar CD) into a
Windows-specific drive-letter (D: or is it E:?), when Windows doesn't even
have volume-names?

The only solution I can think of is for a human with some knowledge of the
file-system to create a mapping table (Hashtable or other Map), or assist
the computer in the creation of one. This table would translate some
predetermined portion of the Mac-specific pathname into a platform-specific
base-location, i.e. a File representing a "directory" location. Just
remember that no algorithm is going to work perfectly, so human
intervention in creating the table is needed.


>Is there a preferred way to enumerate volumes on OS X, and how does one
>reconcile this with the other platforms?

There is no way to "enumerate volumes" from Java, without the use of some
external library. The very concept of "a volume" may change across
platforms, too. For example, not all mounted file-systems on Mac OS X (or
other Unix-ish OSes) represent a user-perceivable volume. Type 'mount' in
Terminal to see what I mean.

JConfig was already mentioned, though you'll probably still need human
intervention to map "Foobar CD" to a corresponding "volume" on a given
platform.

You might also find my Easy Posix Toolkit useful on Mac OS X, especially
Environs.getMounted(), which returns an array of MountInfo's representing
every mounted file-system:
<http://www.amug.org/~glguerin/sw/#easyposix>

Also, I think Pathname and PathnameFormat may be useful for doing pathname
parsing and conversion. You'll have to create a PathnameFormat subclass to
handle the classical colon-separated Mac format, but this should do it:
new PathnameFormat( ':', false )

-- GG
_______________________________________________
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.



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.