Re: Volume status
Re: Volume status
- Subject: Re: Volume status
- From: Graff <email@hidden>
- Date: Fri, 01 Oct 2004 14:41:04 -0400
On Oct 1, 2004, at 1:39 PM, Adam K. Wuellner wrote:
On Oct 1, 2004, at 11:35 AM, Adam K. Wuellner wrote:
I used 'properties of disk 3' in a Finder tell block to get the
following information:
{<snip>}
As you can see, you can determine the owner, group, permissions, free
space, file system format, etc. Does this give you what you need?
I noticed I got nothing that would tell me wether I can write to my
mounted disk images... for that, turn to do shell script and hdiutil:
do shell script "hdiutil info"
hdiutil is only useful for disk images. In general you are better off
using diskutil for this since it will handle all mounted volumes.
Here's a handler that will check if a disk is read-only or not:
----
on IsDiskReadOnly(theName)
-- need to shorten name because "diskutil list"
-- name output is limited to 32 characters
if (length of theName > 32) then
set shortName to text 1 through 32 of theName
else
set shortName to theName
end if
set searchString to quoted form of shortName
set theResult to do shell script "diskutil info `diskutil list | grep
-F " & ¬
searchString & " | awk '{ print $NF }'` | awk '/Read Only:/{ print $3
}'"
if (theResult contains "Yes") then
return true
else
return false
end if
end IsDiskReadOnly
-- test case
tell application "Finder"
set diskName1 to name of disk 1 -- a hard drive
set diskName3 to name of disk 3 -- a DVD-ROM
end tell
if IsDiskReadOnly(diskName1) then --> false
display dialog "disk 1 is read-only"
else
-- this should display
display dialog "disk 1 is not read-only"
end if
if IsDiskReadOnly(diskName3) then --> true
-- this should display
display dialog "disk 3 is read-only"
else
display dialog "disk 3 is not read-only"
end if
----
The only glitch that I can see with this script is if you have two
disks that have names which are the same up to the first 32 characters.
That's not too likely so I didn't bother checking it.
- Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden