Re: NSOpenPanel & NSFileTypeForHFSTypeCode
Re: NSOpenPanel & NSFileTypeForHFSTypeCode
- Subject: Re: NSOpenPanel & NSFileTypeForHFSTypeCode
- From: Chris Heimark <email@hidden>
- Date: Thu, 11 Oct 2007 06:08:38 -0400
That is a great approach, not unlike mine of wrapping 'duskutil' in
an 'sh'ell to do all my parsing for essentially same information,
witness:
mainCommand()
{
for _volumeMountName in $(ls /Volumes/* | grep ":" | sed s/://)
do
diskutil info $_volumeMountName | sed -e s/^\ \ \ // -e s/[\ ]$// |
while IFS=: read _infoName _infoValue
do
_infoValue=`echo $_infoValue | sed s/^[\ ]//`
if [ "$_infoName" = "" ]
then
continue
fi
# echo "'$_infoName'=='$_infoValue'"
case "$_infoName" in
"Mount Point") # sanity
if [ "$_infoValue" != "$_volumeMountName" ]
then
echo "UNQUALIFIED: $_volumeMountName"
break
fi
;;
"Read Only") # cannot use this kind of device
if [ "$_infoValue" = "Yes" ]
then
echo "UNQUALIFIED: $_volumeMountName"
break
fi
;;
"Protocol") # MUST be USB based
if [ "$_infoValue" != "USB" ]
then
echo "UNQUALIFIED: $_volumeMountName"
break
fi
;;
"Free Space") # cache the space available
_SPACE=$_infoValue
;;
"UUID") # cache the UUID for future use if qualified
_UUID=$_infoValue
;;
"Ejectable") # has to be a plug in volume (last info piece as well)
if [ "$_infoValue" = "No" ]
then
echo "UNQUALIFIED: $_volumeMountName"
break
else
# here is the final candidate
echo "QUALIFIED: $_volumeMountName, UUID: $_UUID, SPACE: $_SPACE"
break
fi
;;
esac
done
done
}
mainCommand;
Yielding, on my system, with just 1 USB drive attached:
UNQUALIFIED: /Volumes/Remember
UNQUALIFIED: /Volumes/TitaniumData
UNQUALIFIED: /Volumes/TitaniumTemp
UNQUALIFIED: /Volumes/TitaniumTiger
QUALIFIED: /Volumes/chessy, UUID:
F9DC83F2-0C29-3F9E-8176-67C62877F365, SPACE: 112.8 MB
So at least two approaches for finding qualified /volumes to present
to user. Thanks for your help!
On Oct 10, 2007, at 11:11 PM, Steve Checkoway wrote:
On Oct 10, 2007, at 2:18 PM, Chris Heimark wrote:
I am going to qualify the list of usable volumes for my
application using NSTask running diskutil and filtering ONLY for
the volumes I want - which in my case are USB mounted flash
drives. So I may just end up with a NSPopupButton selector filled
with only qualified volumes. So '/' will not be one of them...
What I ended up doing in this case was use getfsstat and iterate
over the mounted file systems looking for those with f_mntfromname
that starts with /dev and then use the IOKit to check if it is a
mass storage device.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden