Created
August 26, 2013 03:47
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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