eduffy eduffy - 4 months ago 60
Objective-C Question

Is there a way to programmatically connect to a remote server from Cocoa?

Is there an Coca/obj-C API call to mimic the "Connect to Server" action in Finder? It's possible with Automater, so it seems like Finder has a hook somewhere.


Turns out there's an old Carbon function (can't find a Cocoa equivalent) called FSMountServerVolumeSync which does what I was looking for. You can supply and smb:// URL and login credentials.

File Manager Reference

OSStatus FSMountServerVolumeSync (
  CFURLRef url,
  CFURLRef mountDir,
  CFStringRef user,
  CFStringRef password,
  FSVolumeRefNum *mountedVolumeRefNum,
  OptionBits flags