Recent

Author Topic: need to access DADiskCreateFromVolumePath function from DADisk  (Read 1013 times)

inferno

  • New Member
  • *
  • Posts: 34
need to access DADiskCreateFromVolumePath function from DADisk
« on: September 11, 2021, 09:57:34 am »
Hi all,
I need to use DADiskCreateFromVolumePath on macOS platform: https://developer.apple.com/documentation/diskarbitration/1401858-dadiskcreatefromvolumepath?language=objc
It persists in /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/DiskArbitration.framework/Versions/A/Headers/DADisk.h

Code: Pascal  [Select][+][-]
  1. /*!
  2.  * @function   DADiskCreateFromVolumePath
  3.  * @abstract   Creates a new disk object.
  4.  * @param      allocator The allocator object to be used to allocate memory.
  5.  * @param      session   The DASession in which to contact Disk Arbitration.
  6.  * @param      path      The BSD mount point.
  7.  * @result     A reference to a new DADisk.
  8.  * @discussion
  9.  * The caller of this function receives a reference to the returned object.  The
  10.  * caller also implicitly retains the object and is responsible for releasing it
  11.  * with CFRelease().
  12.  */
  13.  
  14. extern DADiskRef __nullable DADiskCreateFromVolumePath( CFAllocatorRef __nullable allocator, DASessionRef session, CFURLRef path );

but no in the translated Pascal unit: /fpcbuild-3.2.2/fpcsrc/packages/univint/src/DADisk.pas

I tried to add it myself without success:

Code: Pascal  [Select][+][-]
  1. function DADiskCreateFromVolumePath(allocator: CFAllocatorRef;  session: DASessionRef; path: CFURLRef ): DADiskRef; external name '_DADiskCreateFromVolumePath';

The compiler returns: Error: Identifier not found "DADiskCreateFromVolumePath".

Any idea how to access this call?

Best regards,
Inferno
« Last Edit: September 11, 2021, 09:59:18 am by inferno »

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 922
Re: need to access DADiskCreateFromVolumePath function from DADisk
« Reply #1 on: September 11, 2021, 01:37:50 pm »
Where did you add this declaration?

inferno

  • New Member
  • *
  • Posts: 34
Re: need to access DADiskCreateFromVolumePath function from DADisk
« Reply #2 on: September 11, 2021, 02:07:08 pm »
To the DADisk.pas file.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 922
Re: need to access DADiskCreateFromVolumePath function from DADisk
« Reply #3 on: September 11, 2021, 02:32:12 pm »
An installed FPC uses the pre-compiled units that come with it, so adding something to the sources indeed won't change anything. Better add it to a utility unit of your own. Don't forget to add mwpascal;`at the end of the declaration though, because that calling convention is the default in the universal interfaces units.

inferno

  • New Member
  • *
  • Posts: 34
Re: need to access DADiskCreateFromVolumePath function from DADisk
« Reply #4 on: September 11, 2021, 09:09:34 pm »
This was the cause. I already had my own DADisk unit version, but I missed to add it to the project, so compiler used original fpc unit where I also tried to add the DADiskCreateFromVolumePath declaration. Too much mess during experiments...

Thank you Jonas!

Best regards,
Inferno

 

TinyPortal © 2005-2018