Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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