Last active
March 29, 2017 20:53
-
-
Save chamons/4a58fcfda110dec747d188c76c228ee9 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Runtime.InteropServices; | |
using AppKit; | |
using CoreFoundation; | |
using System.Collections.Specialized; | |
using Foundation; | |
namespace TestMap2 { | |
static class MainClass { | |
static void Main(string[] args) { | |
NSApplication.Init(); | |
NSArray mtPoints; | |
var Test = | |
MountUrl( | |
"http://127.0.0.1:8881/", | |
"/Users/TonyValenti/AlphaDrive", | |
"NoUser", | |
"NoPass", | |
null, | |
null, | |
out mtPoints | |
); | |
NSApplication.Main(args); | |
} | |
public static int MountUrl(string Url, string MountPath, string UserName, string Password, StringDictionary OpenOptions, StringDictionary MountOptions, out NSArray MountPoints) { | |
var CUrl = CFUrl.FromUrlString(Url, null); | |
var CMountPath = CFUrl.FromFile(MountPath); | |
var CUserName = (NSString)UserName; | |
var CPassword = (NSString)Password; | |
var COpenOptions = new NSMutableDictionary(); | |
var CMountOptions = new NSMutableDictionary(); | |
IntPtr mountPoints = IntPtr.Zero; | |
var retVal = NetFSMountURLSync( | |
CUrl.Handle, | |
CMountPath.Handle, | |
CUserName.Handle, | |
CPassword.Handle, | |
COpenOptions.Handle, | |
CMountOptions.Handle, | |
out mountPoints | |
); | |
mtPoints = ObjCRuntime.Runtime.GetNSObject <NSArray> (mountPoints); | |
return retVal; | |
} | |
[DllImport("/System/Library/Frameworks/NetFS.framework/NetFS")] | |
static extern int NetFSMountURLSync(IntPtr url, IntPtr mountpath, IntPtr user, IntPtr passwd, IntPtr open_options, IntPtr mount_options, out IntPtr mountpoints); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment