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: Names of drives (was Re: A little help for a Mac newbie? :-))



I thought I was remembering a way to get this from Java without resorting to native of some sort. Since no one has indicated it yet. If you are dealing with Carbon API's that expect Classic type paths you will at some point need to do the translation as Glen indicated.

What I do JNIDirect, you could probably translate to JNI if you're familiar with that is...

if (abspath.indexOf("/Volumes/") > -1) // A non-boot path?
sErr = set(abspath.substring(abspath.indexOf("/Volumes/") + 9),this);
else sErr = set(File.separator + bootvol() + file.getAbsolutePath(),this);

bootvol() ends up calling...

public synchronized static String getSysVolName() {
short err;
short [] vRefNum = new short[1];
try {
// JDirectLocking.acquire();
err = macnative.jnidirect.MoreFileUtils.getSysVolume(vRefNum);
if (err != (short)0) throw new NullPointerException("FSSpec: Unable to obtain system volume - FindFolder" + err);
char [] name = new char[256];
err = FSGetVolumeInfo(vRefNum[0],0,0,0,0,name,0);
short strlen = (short)name[0];
return new String(name,1,strlen);
}
catch (Exception ex) { ex.printStackTrace(); return null; }
// finally { JDirectLocking.release(); }
}

////////////////////////////////////////////////////////////
// GetSysVolume //
// Get the vRefNum of the system (boot) volume //
////////////////////////////////////////////////////////////
public static short getSysVolume(short [] vRefNum) {
int [] dir = new int[1];
try {
// CarbonLock.acquire();
return FindFolder(kOnSystemDisk,kSystemFolderType,false,vRefNum,dir);
}
finally { /* CarbonLock.release(); */ }
}



Mike Hall <mikehall at spacestar dot net>
<http://www.spacestar.net/users/mikehall>
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Names of drives (was Re: A little help for a Mac newbie? :-)) (From: Moises Lejter <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.