Skip to content

Instantly share code, notes, and snippets.

@manchicken
Created August 26, 2013 03:47
Show Gist options
  • Save manchicken/6337966 to your computer and use it in GitHub Desktop.
Save manchicken/6337966 to your computer and use it in GitHub Desktop.
This is a snippet of a program I wrote a LONG time back. This actually lets you use ascript to mount a network drive onto a local mount point. I used this as part of an application I was working on to mount Windows (CIFS mostly) shares onto Mac workstations. NOTE: This code probably doesn't compile (definitely doesn't), and it would take some wo…
#define APPLESCRIPT_MOUNT_SCRIPT(X) [\
NSString \
stringWithFormat:@"tell application \"Finder\" to mount volume \"%@\"",\
X\
]
- (BOOL) mount {
NSAppleScript *ascript = [[NSAppleScript alloc]
initWithSource:APPLESCRIPT_MOUNT_SCRIPT(originalPath)];
NSDictionary *errorInfo = nil;
NSLog(@"Mounting: '%@' to '%@'...",[self remotePath], [self localPath]);
[ascript executeAndReturnError:&errorInfo];
[ascript release];
if (errorInfo != nil) {
NSLog(@"Got this in error info: %@", errorInfo);
[errorInfo release];
alertUser([NSString stringWithFormat:@"Failed to open path '%@'.", cifsPath]);
return NO;
}
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment