I’m a simple guy (which means maybe I shouldn’t be in the computer biz) so when I traverse the Volumes array in Xojo I want to see REAL Volumes, like ‘Macintosh HD’ or ‘My External Drive’ or just simply the names of the Volumes that I see in the Finder.
What I DON’T want to see is all this symlink geeky stuff like ‘home’ or ‘etc’ or ‘net’. I see this stuff more often in Lion/ML/Mav than I do in 10.6 or earlier. And of course, my system is pretty simple - I got clients that do all sorts of funky stuff.
I had for awhile eliminated viewing volumes called ‘home’ or ‘etc’ or ‘net’ but then I got a client who actually had a real drive he called HOME.
My question is: how can you identify these superfluous Volumes and just get the ones that show up in the Finder - the ones that truly represent file-containing storage areas?
These “superfluous Volumes” need of course to be included because they are not superfluous for others. It is your job to filter them out. Look at the properties of the FolderItem class - since Volume(index) returns a FolderItem. For example DesktopFolder will be Nil unless it is the main volume. And so on…
Volumes:
FolderItem.Locked is False for the main volume and regular mounted disks. It is True example for the volume MobileBackups, home and net.
Folders:
Dim arr() As FolderItem
Dim volume As FolderItem = Volume(0)
For i As Integer = 1 To volume.Count
Dim firstChar As String = volume.Item(i).Name.Left(1)
If Asc(firstChar) >= Asc("A") And Asc(firstChar) <= Asc("Z") Then
arr.Append(volume.Item(i))
End
Next
This will show all folders on the main volume which start with an uppercase letter (these folders are the ones visible for the user on OS X).
There is nothing that says an OSX volume must start or not start with an UpperCase Letter to be displayed.
you can have legit disk volumes with lowercase names… it is just a matter of convention that the OSX underlying volumes are named that way… but nothing stops an end user from doing the same
I happen to have an external drive volume named “home” [lowercase]
For i As Integer = 0 To volumeCount-1
if volume(i)<>nil then
// Select where GROUP is not "wheel"
msgbox str(i)+":"+volume(i).name+"/"+volume(i).Group+"/"+str(volume(i).locked)
end if
Next
Plus it is bad practice to name a variable the same as an existing function… especially since VOLUME and VOLUMECOUNT are pre-defined already
the system disks all belong to group “wheel” and will be locked… other disks will probably belong to group “staff”, and MAY not be locked (the user can lock the volumes too)