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.
views:
49answers:
3For a remote server (like `smb://`)? I'm pretty sure `mount` is for local devices only.
eduffy
2010-07-30 18:52:52
Works on Linux at least - you specify it as //server.name/share/path/to/folder
Paul Betts
2010-07-30 18:57:31
+2
A:
An easy way is to just run some applescript code. I'll show you 2 choices. This first one is the standard way to show that Finder window from applescript.
NSString* cmd = @"choose URL";
The resulting window is bare-bones though, so you can actually open the Finder's window with this command...
NSString* cmd = @"tell application \"Finder\" to activate\ndelay 0.2\ntell aplication \"System Events\" to keystroke \"k\" using command down";
After choosing either of the "cmd" strings, you can execute that applescript code with this...
NSAppleScript* theScript = [[NSAppleScript alloc] initWithSource:cmd];
[theScript executeAndReturnError:nil];
[theScript release];
regulus6633
2010-08-01 22:36:15
+1
A:
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.
OSStatus FSMountServerVolumeSync (
CFURLRef url,
CFURLRef mountDir,
CFStringRef user,
CFStringRef password,
FSVolumeRefNum *mountedVolumeRefNum,
OptionBits flags
);
eduffy
2010-10-31 18:38:53