public CryptoMirror(string root, char letter, string label) { this.root = root; this.mountPoint = letter + mountPointEnd; this.label = label; encryptor = new Encryptor(Encoding.Default.GetBytes(internalKey)); Options = new DokanOptions(); Options.DebugMode = false; Options.MountPoint = mountPoint; Options.ThreadCount = threadCount; Options.VolumeLabel = label; }
public Proxy(DokanOptions options, DokanOperations operations) { operations_ = operations; options_ = options; array_ = new ArrayList(); infoTable_ = new Dictionary<ulong, DokanFileInfo>(); }
private static bool MountFS(DokanOperations dok, string driveLetter, string driveLabel, out string errorMessage) { DokanOptions opt = new DokanOptions(); opt.DebugMode = true; opt.MountPoint = driveLetter + ":\\"; opt.VolumeLabel = driveLabel; opt.ThreadCount = 5; int status = DokanNet.DokanMain(opt, new LoggingFS(dok, true)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: errorMessage = "Drvie letter error"; return false; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: errorMessage = "Driver install error"; return false; case DokanNet.DOKAN_MOUNT_ERROR: errorMessage = "Mount error"; return false; case DokanNet.DOKAN_START_ERROR: errorMessage = "Start error"; return false; case DokanNet.DOKAN_ERROR: errorMessage = "Unknown error"; return false; case DokanNet.DOKAN_SUCCESS: errorMessage = ""; return true; default: errorMessage = "Unknown status: " + status; return false; } }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.MountPoint = "r:\\"; opt.DebugMode = true; opt.UseStdErr = true; opt.VolumeLabel = "CacheDrive"; int status = DokanNet.DokanMain(opt, new CachingFileSystem("S:\\")); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.MountPoint = RoleEnvironment.GetConfigurationSettingValue("Two10.AzureBlobDrive.DriveLetter"); opt.DebugMode = true; opt.UseStdErr = true; opt.VolumeLabel = "AZURE"; int status = DokanNet.DokanMain(opt, new AzureOperations(RoleEnvironment.GetConfigurationSettingValue("Two10.AzureBlobDrive.AzureConnectionString"))); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Trace.WriteLine("Drive letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Trace.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Trace.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Trace.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Trace.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Trace.WriteLine("Success"); break; default: Trace.WriteLine(string.Format("Unknown status: %d", status)); break; } }
public static int Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); var dokanOptions = new DokanOptions { MountPoint = "r:\\", DebugMode = true, UseStdErr = true, VolumeLabel = "TAGFS", ThreadCount = 1 }; var options = new TaggedFileSystemOptions { RootPath = "d:\\tmp" }; options.Init(); var databaseOriginal = new Database(options.ServicePath); var taggedFileStorage = new TaggedFileStorage(databaseOriginal); var target = new TaggedFileSystem(options, taggedFileStorage); var fileSystemPxy = new ProxyGenerator() .CreateInterfaceProxyWithTarget<DokanOperations>( target, new WrappingInterceptor(), new TransactionManagementInterceptor(databaseOriginal) ); var status = DokanNet.DokanMain( dokanOptions, fileSystemPxy ); return status; }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.DriveLetter = 'r'; opt.NetworkDrive = true; opt.DebugMode = false; opt.UseAltStream = false; opt.UseKeepAlive = true; opt.UseStdErr = true; opt.VolumeLabel = "MSSQLFS"; String Server = "", Database = "", User = "", Password = ""; opt.DriveLetter = (System.Configuration.ConfigurationSettings.AppSettings["drive"] != null) ?System.Configuration.ConfigurationSettings.AppSettings["drive"][0] : 'r'; Server = System.Configuration.ConfigurationSettings.AppSettings["server"]; Database = System.Configuration.ConfigurationSettings.AppSettings["database"]; User = System.Configuration.ConfigurationSettings.AppSettings["user"]; Password = System.Configuration.ConfigurationSettings.AppSettings["password"]; foreach (String arg in args) { if (Regex.Match(arg, "/drive:.").Success) opt.DriveLetter = Regex.Split(arg, "/drive:")[1][0]; if (Regex.Match(arg, "/server:*").Success) Server = Regex.Split(arg, "/server:")[1]; if (Regex.Match(arg, "/database:*").Success) Database = Regex.Split(arg, "/database:")[1]; if (Regex.Match(arg, "/user:*").Success) User = Regex.Split(arg, "/user:"******"/password:*").Success) Password = Regex.Split(arg, "/password:"******"Data Source={0};Initial Catalog={1};Integrated Security=False;User ID={2};Password={3};Pooling=true;Min Pool Size=1;Max Pool Size=5;Connect Timeout=500", Server, Database, User, Password); DokanNet.DokanMain(opt, new MSSQLFS(ConnString)); }
public static void _DokanMount(object _wm) { WinMounter wm = (WinMounter)_wm; DokanOptions opt = new DokanOptions(); PutioDokanOperations ops = new PutioDokanOperations(wm); opt.DebugMode = false; opt.DriveLetter = ops.Mounter.DriveLetter; opt.ThreadCount = 5; opt.VolumeLabel = "put.io"; // opt.NetworkDrive = true; DokanNet.DokanMain(opt, ops); }
public void TestDokanTest() { //for (int retries = 0; retries < 2; retries++) { DokanOptions opt = new DokanOptions(); var FileSystem = new LocalFileSystem(@"C:\temp\temp2"); var FileSystem2 = new SftpFileSystem("192.168.1.36", 22, "ubuntu", "ubuntu", 1000); var FileSystem3 = new FtpFileSystem("192.168.1.36", 21, "ubuntu", "ubuntu", 1000); FileSystem.Mount("/MountedFolder/sftp", FileSystem2); FileSystem.Mount("/MountedFolder/ftp", FileSystem3); opt.MountPoint = @"m:\"; opt.DebugMode = true; opt.UseStdErr = true; opt.NetworkDrive = true; opt.RemovableDrive = false; opt.VolumeLabel = "Test"; Thread.GetDomain().ProcessExit += new EventHandler(delegate(object sender, EventArgs e) { DokanNet.DokanUnmount('m'); }); int status = DokanNet.DokanMain(opt, new FileSystemProxyDokanOperations(FileSystem)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); //Thread.Sleep(2000); //continue; break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } Console.ReadKey(); //break; } }
static void Main() { Console.WriteLine("Connecting to GridFS"); var gfs = new GridFs( Settings["MongoDBConnectionString"], Settings["GridFSDB"], Settings["PrefixPath"] ); var opt = new DokanOptions{ #if DEBUG DebugMode = true, #endif MountPoint = Settings["MountPoint"], ThreadCount = 1, }; Console.WriteLine("Mounting {0}",Settings["MountPoint"]); AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit; var status = DokanNet.DokanMain(opt, gfs); gfs.Dispose(); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: {0}", status); break; } }
public void mount(string driveLetter) { List<Root> roots = new List<Root>(); foreach (string item in listBox1.Items) { roots.Add(new Root(item)); } mfs = new MergedFileSystem(this,roots); DokanOptions opt = new DokanOptions(); opt.DebugMode = false; opt.MountPoint = driveLetter+":\\"; opt.ThreadCount = 5; opt.VolumeLabel = "MergeFS"; opt.RemovableDrive = false; opt.NetworkDrive = false; int status = DokanNet.DokanMain(opt, mfs); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
public Main() { Application.ApplicationExit += new EventHandler(this.OnApplicationExit); InitializeComponent(); TrayIcon.Visible = true; DokanOptions opt = new DokanOptions(); opt.MountPoint = driveLetter.Value.ToString(); opt.VolumeLabel = "Storj"; opt.UseStdErr = true; opt.UseKeepAlive = false; dokanTask = Task.Factory.StartNew(() => DokanNet.DokanMain(opt, new StorjOperations(OnCommunication))); TrayIcon.BalloonTipTitle = "Storj Virtual Disk ready"; TrayIcon.BalloonTipText = "The Storj Virtual Disk successfully mounted to drive '" + driveLetter + "' and is now ready to use."; TrayIcon.ShowBalloonTip(TimeSpan.FromSeconds(5).Milliseconds); }
static void Main(string[] args) { //args = new string[] { @"C:\VPC\SmartOs\" }; if (args.Length == 0) { Console.WriteLine("Usage: ZfsSharp.exe <a directory containing VHD, VDI, or ZFS files>"); return; } using (var zfs = new Zfs(args[0])) { DokanOptions opt = new DokanOptions(); opt.MountPoint = "z:\\"; opt.DebugMode = true; opt.UseStdErr = true; opt.VolumeLabel = "ZFS"; int status = DokanNet.DokanMain(opt, new ZfsDokan(zfs)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: {0}", status); break; } } }
static void mountFS() { DokanOptions opt = new DokanOptions(); opt.MountPoint = "r:\\"; opt.DebugMode = false; //opt.UseStdErr = true; opt.VolumeLabel = "MediawikiFS"; //opt.UseKeepAlive = true; //opt.UseAltStream = true; opt.RemovableDrive = true; int status = DokanNet.DokanMain(opt, new MWFS(serverUrl, serverUser, serverPassword)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); Console.WriteLine("Mounted. Close window to unmount."); //Process.Start("explorer.exe", @"r:\"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.MountPoint = ConfigurationManager.AppSettings["DriveLetter"]; opt.DebugMode = true; opt.UseStdErr = true; opt.VolumeLabel = "AZURE"; // in case the volume has already been mounted DokanNet.DokanUnmount(opt.MountPoint[0]); int status = DokanNet.DokanMain(opt, new AzureOperations(ConfigurationManager.AppSettings["AzureConnectionString"], "test")); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Trace.WriteLine("Drive letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Trace.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Trace.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Trace.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Trace.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Trace.WriteLine("Success"); break; default: Trace.WriteLine(string.Format("Unknown status: %d", status)); break; } }
static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("flacFS - a virtual file system for flac images"); Console.WriteLine("Usage: flacFs /src/directory /mount/point"); Console.WriteLine(""); Console.WriteLine("Notes for Windows:"); Console.WriteLine("a. mount point is a drive letter."); Console.WriteLine("b. if an argument contains space characters, it should be enclosed in double quotes."); Console.WriteLine("c. the backspace at the end of a path in quotes should be escaped."); return; } string srcDirectory = System.IO.Path.GetFullPath(args[0]); string mountPoint = args[1]; const string volumeLabel = "flacFs"; if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == (PlatformID)128) // 128 is defined by Mono as Unix { using (FlacFuse flacFuse = new FlacFuse(srcDirectory)) { flacFuse.MountPoint = mountPoint; flacFuse.Name = volumeLabel; flacFuse.Start(); } } else { DokanOptions opt = new DokanOptions(); opt.MountPoint = mountPoint; //opt.DebugMode = true; //opt.UseStdErr = true; opt.VolumeLabel = volumeLabel; DokanNet.DokanMain(opt, new FlacDokan(srcDirectory)); } }
static int Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Exception eObj = e.ExceptionObject as Exception; string errorMessage = "FATAL ERROR: " + eObj; Trace.TraceError(errorMessage); Console.Error.WriteLine(errorMessage); Environment.Exit(-1); }; if (args.Length < 1) { string usageStr = Program.formatUsageString(); Console.Error.WriteLine(usageStr); return -1; } ConfigurationManager configMan = new ConfigurationManager(args[0]); MergedVolumeInfo volumeInfo = configMan.ReadConfiguration(); string assemblyGuid = Program.getAssemblyGuid(); using (TraceListener etwListener = new EventProviderTraceListener(assemblyGuid)) { Trace.Listeners.Add(etwListener); AufsImpl aufsImplObj = new AufsImpl(volumeInfo); DokanOptions options = new DokanOptions(); options.DebugMode = false; options.UseStdErr = false; options.ThreadCount = 0; // use default thread count options.MountPoint = volumeInfo.DriveLetter + @":\"; options.VolumeLabel = volumeInfo.DriveLabel; DokanNet.DokanMain(options, aufsImplObj); } DokanNet.DokanUnmount(volumeInfo.DriveLetter); return 0; }
public RAFMount(RM rafManager) { //Console.SetOut(TextWriter.Null); DokanOptions options = new DokanOptions(); options.DebugMode = true; options.MountPoint = "r:\\"; options.ThreadCount = 1; int status = DokanNet.DokanMain(options, new RAFArchiveOperations(rafManager)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.DriveLetter = 'r'; opt.DebugMode = true; opt.UseStdErr = true; opt.VolumeLabel = "RFS"; DokanNet.DokanMain(opt, new RFS()); }
private void MountDrive() { if (!connected) { MessageBox.Show("Client not connected!"); } if (nfsClient == null) throw new ApplicationException("NFS object is null!"); MountPoint = String.Format(@"{0}:\", "Z"); /* if (!DiskOrFolder) { if (!Directory.Exists(Folder)) throw new ApplicationException(String.Format("{0} not found.", Folder)); else MountPoint = Folder; } */ bool NoCache = true; ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { try { System.IO.Directory.SetCurrentDirectory(Application.StartupPath); DokanOptions dokanOptions = new DokanOptions(); dokanOptions.DebugMode = false; dokanOptions.NetworkDrive = false; dokanOptions.RemovableDrive = true; dokanOptions.MountPoint = MountPoint; dokanOptions.UseKeepAlive = true; dokanOptions.UseAltStream = true; dokanOptions.VolumeLabel = this.Text; dokanOptions.ThreadCount = 1; if (NoCache) dokanOperation = new Operations(nfsClient,this); else dokanOperation = new CacheOperations(new Operations(nfsClient,this)); int status = DokanNet.DokanMain(dokanOptions, dokanOperation); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: throw new ApplicationException("Drvie letter error"); case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: throw new ApplicationException("Driver install error"); case DokanNet.DOKAN_MOUNT_ERROR: throw new ApplicationException("Mount error"); case DokanNet.DOKAN_START_ERROR: throw new ApplicationException("Start error"); case DokanNet.DOKAN_ERROR: throw new ApplicationException("Unknown error"); case DokanNet.DOKAN_SUCCESS: break; default: throw new ApplicationException("Unknown status: " + status); } } catch (Exception ex) { MessageBox.Show(ex.Message); } })); ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { Thread.Sleep(2000); Process.Start("explorer.exe", " " + MountPoint); })); mountedDrive = true; }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.DebugMode = true; opt.MountPoint = "n:\\"; opt.ThreadCount = 5; int status = DokanNet.DokanMain(opt, new Mirror("C:")); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: %d", status); break; } }
public static int DokanMain(DokanOptions options, DokanOperations operations) { if (options.VolumeLabel == null) { options.VolumeLabel = "DOKAN"; } Proxy proxy = new Proxy(options, operations); DOKAN_OPTIONS dokanOptions = new DOKAN_OPTIONS(); dokanOptions.Version = options.Version; if (dokanOptions.Version == 0) { dokanOptions.Version = DOKAN_VERSION; } dokanOptions.ThreadCount = options.ThreadCount; dokanOptions.Options |= options.DebugMode ? DOKAN_OPTION_DEBUG : 0; dokanOptions.Options |= options.UseStdErr ? DOKAN_OPTION_STDERR : 0; dokanOptions.Options |= options.UseAltStream ? DOKAN_OPTION_ALT_STREAM : 0; dokanOptions.Options |= options.UseKeepAlive ? DOKAN_OPTION_KEEP_ALIVE : 0; dokanOptions.Options |= options.NetworkDrive ? DOKAN_OPTION_NETWORK : 0; dokanOptions.Options |= options.RemovableDrive ? DOKAN_OPTION_REMOVABLE : 0; dokanOptions.MountPoint = options.MountPoint; DOKAN_OPERATIONS dokanOperations = new DOKAN_OPERATIONS(); dokanOperations.CreateFile = proxy.CreateFileProxy; dokanOperations.OpenDirectory = proxy.OpenDirectoryProxy; dokanOperations.CreateDirectory = proxy.CreateDirectoryProxy; dokanOperations.Cleanup = proxy.CleanupProxy; dokanOperations.CloseFile = proxy.CloseFileProxy; dokanOperations.ReadFile = proxy.ReadFileProxy; dokanOperations.WriteFile = proxy.WriteFileProxy; dokanOperations.FlushFileBuffers = proxy.FlushFileBuffersProxy; dokanOperations.GetFileInformation = proxy.GetFileInformationProxy; dokanOperations.FindFiles = proxy.FindFilesProxy; dokanOperations.SetFileAttributes = proxy.SetFileAttributesProxy; dokanOperations.SetFileTime = proxy.SetFileTimeProxy; dokanOperations.DeleteFile = proxy.DeleteFileProxy; dokanOperations.DeleteDirectory = proxy.DeleteDirectoryProxy; dokanOperations.MoveFile = proxy.MoveFileProxy; dokanOperations.SetEndOfFile = proxy.SetEndOfFileProxy; dokanOperations.SetAllocationSize = proxy.SetAllocationSizeProxy; dokanOperations.LockFile = proxy.LockFileProxy; dokanOperations.UnlockFile = proxy.UnlockFileProxy; dokanOperations.GetDiskFreeSpace = proxy.GetDiskFreeSpaceProxy; dokanOperations.GetVolumeInformation = proxy.GetVolumeInformationProxy; dokanOperations.Unmount = proxy.UnmountProxy; return Dokan.DokanMain(ref dokanOptions, ref dokanOperations); }
private void connect_Click(object sender, EventArgs e) { this.Hide(); int p = 22; sshfs = new SSHFS(); opt = new DokanOptions(); opt.DebugMode = DokanSSHFS.DokanDebug; opt.UseAltStream = true; opt.MountPoint = "n:\\"; opt.ThreadCount = 0; opt.UseKeepAlive = true; string message = ""; if (host.Text == "") message += "Host name is empty\n"; if (user.Text == "") message += "User name is empty\n"; if (port.Text == "") message += "Port is empty\n"; else { try { p = Int32.Parse(port.Text); } catch(Exception) { message += "Port format error\n"; } } if (drive.Text.Length != 1) { message += "Drive letter is invalid\n"; } else { char letter = drive.Text[0]; letter = Char.ToLower(letter); if (!('e' <= letter && letter <= 'z')) message += "Drive letter is invalid\n"; opt.MountPoint = string.Format("{0}:\\", letter); unmount.Text = "Unmount (" + opt.MountPoint + ")"; } opt.ThreadCount = DokanSSHFS.DokanThread; if (message.Length != 0) { this.Show(); MessageBox.Show(message, "Error"); return; } DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked; sshfs.Initialize( user.Text, host.Text, p, usePrivateKey.Checked ? null : password.Text, usePrivateKey.Checked ? privatekey.Text : null, usePrivateKey.Checked ? passphrase.Text : null, root.Text, DokanSSHFS.SSHDebug); if (sshfs.SSHConnect()) { unmount.Visible = true; mount.Visible = false; isUnmounted_ = false; MountWorker worker = null; if (disableCache.Checked) { worker = new MountWorker(sshfs, opt); } else { worker = new MountWorker(new CacheOperations(sshfs), opt); } dokan = new Thread(worker.Start); dokan.Start(); } else { this.Show(); MessageBox.Show("failed to connect", "Error"); return; } MessageBox.Show("sshfs start", "info"); }
public MountWorker(DokanOperations sshfs, DokanOptions opt) { sshfs_ = sshfs; opt_ = opt; }
private void MountDrive() { if (mNFS == null) throw new ApplicationException("NFS object is null!"); string strDev = (string)cboxRemoteDevices.SelectedItem; if (cboxLocalDrive.SelectedItem == null) throw new Exception("You must select a local drive!"); char cDrive = ((string)cboxLocalDrive.SelectedItem).ToCharArray()[0]; MountPoint = String.Format(@"{0}:\", cDrive); string Folder = btnSelectFolder.Text; bool DiskOrFolder = rbDisk.Checked; string strDriveLabel = tbDriveLabel.Text; MainForm.In.mNFS.MountDevice(strDev); cboxLocalDrive.Enabled = false; cboxRemoteDevices.Enabled = false; btnMount.Enabled = false; btnUnmount.Enabled = true; tbDriveLabel.Enabled = false; rbDisk.Enabled = false; rbFolder.Enabled = false; btnSelectFolder.Enabled = false; chkAutoMount.Enabled = false; chkUsePrivilegedPorts.Enabled = false; chkNoCache.Enabled = false; btnClearCache.Enabled = true; if (!DiskOrFolder) { if (!Directory.Exists(Folder)) throw new ApplicationException(String.Format("{0} not found.", Folder)); else MountPoint = Folder; } bool NoCache = chkNoCache.Checked; ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { try { System.IO.Directory.SetCurrentDirectory(Application.StartupPath); DokanOptions dokanOptions = new DokanOptions(); dokanOptions.DebugMode = DebugMode; dokanOptions.NetworkDrive = DiskOrFolder; dokanOptions.MountPoint = MountPoint; dokanOptions.UseKeepAlive = true; dokanOptions.UseAltStream = true; dokanOptions.VolumeLabel = strDriveLabel; dokanOptions.ThreadCount = 1; if (NoCache) dokanOperation = new Operations(); else dokanOperation = new CacheOperations(new Operations()); int status = DokanNet.DokanMain(dokanOptions, dokanOperation); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: throw new ApplicationException("Drvie letter error"); case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: throw new ApplicationException("Driver install error"); case DokanNet.DOKAN_MOUNT_ERROR: throw new ApplicationException("Mount error"); case DokanNet.DOKAN_START_ERROR: throw new ApplicationException("Start error"); case DokanNet.DOKAN_ERROR: throw new ApplicationException("Unknown error"); case DokanNet.DOKAN_SUCCESS: break; default: throw new ApplicationException("Unknown status: " + status); } } catch (Exception ex) { MessageBox.Show(ex.Message); } })); ThreadPool.QueueUserWorkItem(new WaitCallback( delegate { Thread.Sleep(2000); Process.Start("explorer.exe", " " + MountPoint); })); }
private void connect() { int p = 22; sshfs = new SSHFS(); opt = new DokanOptions(); opt.DebugMode = parser.debug; opt.UseAltStream = true; opt.ThreadCount = 0; opt.UseKeepAlive = true; string message = ""; if (parser.host == "") message += "Host name is empty\n"; if (parser.user == "") message += "User name is empty\n"; if (parser.drive.Length != 1) { message += "Drive letter is invalid\n"; } else { char letter = parser.drive[0]; letter = Char.ToLower(letter); if (!('e' <= letter && letter <= 'z')) message += "Drive letter is invalid\n"; opt.MountPoint = string.Format("{0}:\\", letter); unmount.Text = "Unmount (" + opt.MountPoint + ")"; } opt.MountPoint = string.Format("{0}:\\", 'r'); unmount.Text = "Unmount (" + opt.MountPoint + ")"; opt.UseStdErr = parser.debug; opt.ThreadCount = DokanSSHFS.DokanThread; if (message.Length != 0) { MessageBox.Show(message, "Error"); return; } // DokanSSHFS.UseOffline = !withoutOfflineAttribute.Checked; DokanSSHFS.UseOffline = false; //TODO: Add password auth and key passphrase support sshfs.Initialize( parser.user, parser.host, p, null, parser.identity, "", parser.root, DokanSSHFS.SSHDebug); if (sshfs.SSHConnect()) { unmount.Visible = true; mount.Visible = false; isUnmounted_ = false; MountWorker worker = null; // if (disableCache.Checked) // { worker = new MountWorker(sshfs, opt); // } // else // { // worker = new MountWorker(new CacheOperations(sshfs), opt); // } dokan = new Thread(worker.Start); dokan.Start(); } else { MessageBox.Show("failed to connect", "Error"); return; } // MessageBox.Show("sshfs start", "info"); }
protected void Run() { ILogger logger = ServiceRegistration.Get<ILogger>(); try { DokanOptions opt = new DokanOptions { DriveLetter = _driveLetter, VolumeLabel = VOLUME_LABEL, //UseKeepAlive = true, //DebugMode = true, //ThreadCount = 5, //UseAltStream = true, //UseStdErr = true }; // DokanMain will return when a "DokanUnmount" call is done from ResMount thread (or in case of errors?) int result = DokanNet.DokanMain(opt, this); if (result == DokanNet.DOKAN_SUCCESS) logger.Debug("Dokan: DokanMain returned successfully"); else logger.Warn("Dokan: DokanMain returned with error code {0} - remote resources may not be available in this session", result); } catch (Exception e) { logger.Error("Dokan: Error mounting virtual filesystem at drive '{0}' (is DOKAN not installed?)", e, _driveLetter); } }
private static void MountThread(Object ofsmP) { if (ofsmP is OverlayFSMount) { OverlayFSMount ofsm = (OverlayFSMount)ofsmP; String appDirectory = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().Modules[0].FileName) + "\\"; DokanOptions opt = new DokanOptions(); opt.DebugMode = true; opt.MountPoint = ofsm.destination; opt.ThreadCount = 5; opt.RemovableDrive = true; mountedFS.Add(ofsm.destination); int status = DokanNet.DokanMain(opt, new OverlayFS(ofsm.source, appDirectory + "log-" + System.IO.Path.GetFileName(ofsm.destination) + ".txt", ofsm.logLevel)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: EventLog.WriteEntry("OverlayFS", "Drive letter error mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); //Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: //Console.WriteLine("Driver install error"); EventLog.WriteEntry("OverlayFS", "Driver install error mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); break; case DokanNet.DOKAN_MOUNT_ERROR: //Console.WriteLine("Mount error"); EventLog.WriteEntry("OverlayFS", "Mount error mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); break; case DokanNet.DOKAN_START_ERROR: //Console.WriteLine("Start error"); EventLog.WriteEntry("OverlayFS", "Start error mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); break; case DokanNet.DOKAN_ERROR: //Console.WriteLine("Unknown error"); EventLog.WriteEntry("OverlayFS", "Unknown error mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); break; case DokanNet.DOKAN_SUCCESS: //Console.WriteLine("Success"); break; default: //Console.WriteLine("Unknown status: " + status); EventLog.WriteEntry("OverlayFS", "Unknown status: " + status + " mounting " + ofsm.source + " to " + opt.MountPoint, EventLogEntryType.Error); break; } } }
static void Main(string[] args) { DokanOptions opt = new DokanOptions(); opt.DebugMode = false; opt.DriveLetter = 'm'; // Leave to default opt.ThreadCount = 1; opt.VolumeLabel = "MEMFS"; DokanNet.DokanMain(opt, new MemFSje()); }
private static void Main(string[] args) { Settings settings = LoadSettings(); string mountPoint = string.Format(@"{0}:\", settings.DriveLetter); DokanOptions opt = new DokanOptions(); opt.DebugMode = true; opt.MountPoint = mountPoint; opt.ThreadCount = 5; Console.WriteLine("Now you can create symlink to drive {0} using\r\nmklink /D c:\\games\\World_of_Tanks\\res\\gui\\flash\\stat {0}", mountPoint); int status = DokanNet.DokanMain(opt, new StatServer(settings)); switch (status) { case DokanNet.DOKAN_DRIVE_LETTER_ERROR: Console.WriteLine("Drvie letter error"); break; case DokanNet.DOKAN_DRIVER_INSTALL_ERROR: Console.WriteLine("Driver install error"); break; case DokanNet.DOKAN_MOUNT_ERROR: Console.WriteLine("Mount error"); break; case DokanNet.DOKAN_START_ERROR: Console.WriteLine("Start error"); break; case DokanNet.DOKAN_ERROR: Console.WriteLine("Unknown error"); break; case DokanNet.DOKAN_SUCCESS: Console.WriteLine("Success"); break; default: Console.WriteLine("Unknown status: {0}", status); break; } }