GetDriveType in OSX

Normally if I want to know if a drive (and consequently their files) are not in my computer I use GetDriveType in Windows.
Could any user of OSX tell me how should I know that a drive or a file is not in my computer but in a net?
Thanks.

in our NSURLMBS class in MBS Xojo Plugins, you could try NSURLVolumeIsInternalKey, NSURLVolumeIsEjectableKey, NSURLVolumeIsRemovableKey or NSURLVolumeIsLocalKey.

e.g. See the example on the NSURLVolumeIsLocalKey in our documentation.

1 Like

May this help:

for i as integer = 0 to FolderItem.DriveCount-1
  Listbox1.AddRow(FolderItem.DriveAt(i).NativePath + " / "+FolderItem.DriveAt(i).name)
next

You can just use a few declares. No expensive plugin is needed!

Public Function VolumeIsInternal(Extends target as FolderItem) As Boolean
  Soft Declare Function NSClassFromString Lib "AppKit" (classname As CFStringRef) As ptr
  Soft Declare Function fileURLWithPathIsDirectory Lib "Foundation" Selector "fileURLWithPath:isDirectory:" ( NSURLClass As Ptr, path As CFStringRef, directory As Boolean) As Ptr
  Soft Declare Function getResourceValue Lib "Foundation" Selector "getResourceValue:forKey:error:" ( URLRef As Ptr, ByRef value As Ptr, key As CFStringRef, ByRef error As Ptr ) As Boolean
  Soft Declare Function boolValue Lib "Foundation" Selector "boolValue" ( ref As Ptr ) As Boolean // for converting NSNumber boolean to Xojo
  
  Dim NSURLClass As Ptr = NSClassFromString( "NSURL" )
  Dim nativePath As String = target.nativePath
  Dim myURL      As Ptr = fileURLWithPathIsDirectory( NSURLClass, nativePath, target.directory )
  
  Dim error As ptr
  Dim result As ptr
  If Not GetResourceValue( myURL, result, "NSURLVolumeIsInternalKey", error ) Then
    Dim e As new RuntimeException
    e.Message = "An error occurred!"
    Raise e
  End
  
  Return boolValue(result)
End Function

A call example from the opening event of a TextArea

Dim f As FolderItem = New FolderItem("/Volumes/Software")

If f.VolumeIsInternal Then
  Me.AddText f.NativePath + " is internal" + EndOfLine 
Else
  Me.AddText f.NativePath + " is external" + EndOfLine 
End

Thanks to all.
I’ll try to use your suggestions.