Hi,
my projects make use of macOSLib (64-bit). As I said in another post, the only module that does not compile is FileManager; but commenting 5 or 6 lines (not needed in my projects) everything runs all right.
Yet there is a function (DeviceName) that I need, but the debugger stops at f.MacVRefNum: type “folderitem” has no member named MacVRefNum
(6th line of the function, below).
Can anybody tell me how to solve the issue?
[At the end of the DeviceName function-code I pasted also its calling function, where the calling line is the 4th above the bottom].
Thanks.
[code]Public Function DeviceName(extends f as FolderItem) as String
//# DeviceName returns the BSD name of the volume containing f as found in the directory /dev. Only local volumes have such names.
#if TargetMacOS
soft declare function FSGetVolumeParms lib “Cocoa” (ByRef paramBlock as HIOParam) as Int32//or int64?
dim paramBlock as HIOParam
paramBlock.ioVRefNum = f.MacVRefNum// <<< here: type “folderitem” has no member named MacVRefNum
//the following line is a trick to work around the inability to assign a pointer to a structure
//to a field of type Ptr.
dim infoBuffer as new MemoryBlock(GetVolParmsInfoBuffer.Size)
paramBlock.ioBuffer = infoBuffer
paramBlock.ioReqCount = infoBuffer.Size
dim OSError as Integer = FSGetVolumeParms(paramBlock)
if OSError <> 0 then
return ""
end if
dim infoBufferPtr as GetVolParmsInfoBuffer = paramBlock.ioBuffer.GetVolParmsInfoBuffer(0)
if infoBufferPtr.vMServerAddr = 0 then
if infoBufferPtr.vMDeviceID <> nil then
dim s as MemoryBlock = infoBufferPtr.vMDeviceID
dim BSDName as String = s.CString(0)
return DefineEncoding(BSDName, Encodings.SystemDefault)
else
return ""
end if
else
// vMServerAddr <> 0 means it's a network device, which apparently won't have a BSD name.
return ""
end if
#else
#pragma unused f
#endif
End Function
[/code]
//////DeviceName’s calling function:
[code]//# This function, using code from the Apple sample project VolumeToBSDNode, looks up the class name of an IOObject using IO Kit. It will return
//# IOCDMedia for a CD, IODVDMedia for a DVD, and IOMedia for anything else. Thus this function will tell you whether a local volume is a CD or DVD.
//@ It returns "’ for network volumes or if an error occurs.
#if targetMacOS
const IOKitFramework = “IOKit.framework”
const kIOMasterPortDefault = nil //see IOKitLib.h
const IO_OBJECT_NULL = nil
const kIOMediaClass = “IOMedia”
const kIOServicePlane = “IOService”
const kIORegistryIterateRecursively = &h00000001
const kIORegistryIterateParents = &h00000002
const kIOCDMediaClass = “IOCDMedia”
const kIOMediaWholeKey = “Whole”
const kCFAllocatorDefault = nil
soft declare function IOBSDNameMatching lib IOKitFramework (masterPort as Ptr, options as Integer, bsdName as CString) as Ptr
soft declare function IOServiceGetMatchingService lib IOKitFramework (masterPort as Ptr, matching as Ptr) as Ptr
// /usr/include/device/device_types.h:typedef char io_name_t[128];
soft declare function IORegistryEntryCreateIterator lib IOKitFramework (entry as Ptr, plane as CString, options as Integer, ByRef iterator as Ptr) as Integer
soft declare function IOObjectConformsTo lib IOKitFramework (obj as Ptr, className as CString) as Boolean
soft declare function IORegistryEntryCreateCFProperty lib IOKitFramework (entry as Ptr, key as CFStringRef, allocator as Ptr, options as Integer) as Ptr
soft declare function IOObjectGetClass lib IOKitFramework (obj as Ptr, className as Ptr) as Integer
soft declare function IOObjectRetain lib IOKitFramework (obj as Ptr) as Integer
soft declare function IOObjectRelease lib IOKitFramework (obj as Ptr) as Integer
//the documentation for this function suggests that we don’t need to free dPtr (it’s a CFMutableDictionaryRef) because we pass it to IOServiceGetMatchingService
//which consumes a reference. Some testing with CFGetRetainCount confirms this.
dim dPtr as Ptr = IOBSDNameMatching(kIOMasterPortDefault, 0, f.DeviceName)
if dPtr = nil then
return “”
end if[/code]