static void Main(string[] args) { Console.WriteLine(args[0]); String CD = Directory.GetCurrentDirectory(); String[] fs = args[0].Split(';'); foreach (string dir in fs) { FS tln = new FS(); string[] d = dir.Split('='); tln.TLD = Path.Combine(CD, d[0]); if (d.Length == 2) { tln.P = fromstr(d[1]); } else { tln.P = RWPerm.RO; } Console.WriteLine(tln.P.ToString()); lfs.Add(tln); } WinUnion wu = new WinUnion(lfs); DokanOptions opt = DokanOptions.DebugMode; Dokan.Mount(wu, args[1], opt, new NullLogger()); }
private static void Main(string[] args) { var unmountOptions = new UnmountOptions(); if (CommandLine.Parser.Default.ParseArguments(args, unmountOptions)) { Dokan.RemoveMountPoint(unmountOptions.UnmountDirectory); return; } var options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { try { ArchiveManager archiveManager = new ArchiveManager(options.PboDirectories); PboFSTree fileTree = new PboFSTree(archiveManager); PboFS pboFS = new PboFS(fileTree, archiveManager, options.Prefix); pboFS.Mount(options.MountDirectory, Program.MOUNT_OPTIONS); Console.WriteLine("Success"); } catch (DokanException ex) { Console.WriteLine("Error: " + ex.Message); } } }
private static void OnCommonFileSystemWatcherCreated(object sender, FileSystemEventArgs e) { var fullPath = AlterPathToMountPath(e.FullPath); var isDirectory = Directory.Exists(fullPath); Dokan.DokanNotifyCreate(fullPath, isDirectory); }
public void Mount(string drive, string apiUrl, bool debugging) { if (apiUrl != null && apiUrl.Length > 0) { IpfsClient.DefaultApiUri = new Uri(apiUrl); } // Verify that the local IPFS service is up and running var x = new IpfsClient().IdAsync().Result; // CTRL-C will dismount and then exit. Console.CancelKeyPress += (s, e) => { Console.WriteLine("shutting down..."); Unmount(drive); e.Cancel = true; }; // Mount IPFS, doesn't return until the drive is dismounted var options = DokanOptions.WriteProtection; if (debugging) { options |= DokanOptions.DebugMode; } Dokan.Mount(new IpfsDokan(), drive, options, new DokanLogger()); }
public static void Main() { string basePath = Dir(@"c:\projects\Testing\test\Base"); string minePath = Dir(@"c:\projects\Testing\test\Mine"); string workingPath = Dir(@"c:\projects\Testing\test\Working"); DokanOperations mirror = new DokanOperations(basePath, minePath); Task.Factory.StartNew(() => { mirror.Mount(workingPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI, 1, new NullLogger()); }); Console.WriteLine(@"Mounted"); string line; do { line = Console.ReadLine(); Console.Clear(); } while (line != "q"); Dokan.RemoveMountPoint(workingPath); Directory.Delete(workingPath); Console.WriteLine(@"Success"); //MainAsync().Wait(); //Console.WriteLine(@"DONE"); //Console.ReadLine(); }
private void unmountBtn_Click(object sender, EventArgs e) { unmountBtn.Enabled = false; SetFUSEStatus("Unmounting...", Color.Orange); Dokan.Unmount(DriveLetter); SetFUSEStatus("Unmounted.", Color.Red); }
public void UnmountVFS() { if (_dokanTask != null) { try { log.Info($"Unmounting virtual filesystem at {_mountPoint}..."); Dokan.RemoveMountPoint(_mountPoint); if (_dokanTask.Wait(TimeSpan.FromSeconds(10))) { log.Info($"Unmount of {_mountPoint} was successful."); } if (_cleanupMountDirOnExit) { Directory.Delete(_mountPoint); log.Info($"Mountpoint directory {_mountPoint} removed."); } } catch (Exception e) { log.Error("Unmount failed: " + e.Message); } finally { _dokanTask = null; } } }
public void Unmount() { if (this._threadCancel != null) { this._threadCancel.Cancel(); } if (this._pauseEvent != null) { this._pauseEvent.Set(); } Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { Dokan.RemoveMountPoint(String.Format("{0}:\\", mountedLetter)); } catch { //Status = DriveStatus.Unmounted; // OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; } }
public void Unmount() { if (this.reconnectThread != Thread.CurrentThread) { this.stopReconnect(); } if (_threadCancel != null) { _threadCancel.Cancel(); } if (_pauseEvent != null) { _pauseEvent.Set(); } Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { Dokan.RemoveMountPoint($"{Letter}:\\"); _filesystem?.Dispose(); } catch { //Status = DriveStatus.Unmounted; // OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; Status = DriveStatus.Unmounted; OnStatusChanged(EventArgs.Empty); } }
public bool Stop(HostControl hostControl) { Runners.Cancel(); Globals.NotificationCenter.InvokeAsync(x => x.OnServiceStopped()); foreach (var volume in Globals.Database.Table <DiskModel>().ToList()) { try { var mountPoint = Globals.Database.GetMountPoint(volume.Id); Dokan.RemoveMountPoint(mountPoint); if (Globals.Volumes.TryRemove(volume.Id, out var thread)) { thread.Dispose(); } } catch { // Ignored. Terminating. } } Globals.CloudService.Dispose(); Globals.Database.Dispose(); Logger.LogInformation("Windows service stopped."); return(true); }
public void Dispose() { Debug.WriteLine("Dispose"); _threadCancel?.Cancel(); _pauseEvent?.Set(); try { Dokan.RemoveMountPoint($"{Letter}:\\"); if (_filesystem != null) { _filesystem.Dispose(); _filesystem = null; } } catch { if (Status != DriveStatus.Unmounted) { Status = DriveStatus.Unmounted; } } finally { _filesystem = null; } _mountCancel?.Dispose(); _threadCancel?.Dispose(); _pauseEvent?.Dispose(); }
private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e) { Log.Information("Device disconnected", e.Device); List <VirtualDrive> drivesToRemove = new List <VirtualDrive>(); foreach (VirtualDrive d in Devices) { if (e.Device.Serial.Equals(d.AndroidDevice.Serial)) { if (Dokan.Unmount(d.DriveLetter)) { Log.Information("Successfully unmounted drive " + d.DriveLetter); } else { Log.Warning("Error while unmounting " + d.DriveLetter); } drivesToRemove.Add(d); } } foreach (VirtualDrive d in drivesToRemove) { Devices.Remove(d); } }
public static void Mount(MountableFileSystem fs) { if (CanMount()) { char drive = GetAvailableDriveLetter(); Thread thread = new Thread(new ThreadStart(() => { DokanOptions options = DokanOptions.RemovableDrive; if (fs.Mode != OpenMode.ReadWrite) { options |= DokanOptions.WriteProtection; } Dokan.Mount(fs, $"{drive}:", options); } )); if (Mounted.ContainsKey(fs)) { Unmount(fs); } thread.Start(); Mounted[fs] = new Tuple <Thread, char>(thread, drive); } else { MessageBox.Show("Dokan driver seems to be missing. Install the driver and try again."); } }
private static void Main(string[] args) { try { if (args.Length != 2) { Console.WriteLine(@"usage: mountbck.exe S 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\AdventureWorks2014.bak'"); Console.WriteLine("Press any key for exit."); Console.ReadKey(); return; } var driveLetter = args[0][0]; var backupFileName = args[1]; Dokan.Unmount(driveLetter); var backupVfs = new SqlBackupVfs(backupFileName, driveLetter); backupVfs.Mount($"{driveLetter}:\\", DokanOptions.NetworkDrive, 1); Console.WriteLine("Success"); } catch (DokanException ex) { Console.WriteLine("Error: " + ex.Message); } }
public void Dispose() { Debug.WriteLine("Dispose"); if (_threadCancel != null) _threadCancel.Cancel(); if (_pauseEvent != null) _pauseEvent.Set(); try { Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter)); if (_filesystem != null) { _filesystem.Dispose(); _filesystem = null; } } catch { Status = DriveStatus.Unmounted; } finally { _filesystem = null; } if (_mountCancel != null) {_mountCancel.Dispose();} if (_threadCancel != null) {_threadCancel.Dispose();} if (_pauseEvent != null) {_pauseEvent.Dispose();} }
public void Unmount() { Debug.WriteLine("Unmount"); Status = DriveStatus.Unmounting; try { // Dokan.Unmount(Letter); Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter)); if (_filesystem != null) { _filesystem.Dispose(); } } catch { //Status = DriveStatus.Unmounted; // OnStatusChanged(EventArgs.Empty); } finally { _filesystem = null; } }
public static void AssemblyInitialize(TestContext context) { var dokanOptions = DokanOptions.DebugMode | DokanOptions.MountManager | DokanOptions.CurrentSession; #if NETWORK_DRIVE dokanOptions |= DokanOptions.NetworkDrive; #else dokanOptions |= DokanOptions.RemovableDrive; #endif #if USER_MODE_LOCK dokanOptions |= DokanOptions.UserModeLock; #endif Dokan.Init(); safeMount = DokanOperationsFixture.Operations.CreateFileSystem(DokanOperationsFixture.NormalMountPoint, dokanOptions); unsafeMount = DokanOperationsFixture.UnsafeOperations.CreateFileSystem(DokanOperationsFixture.UnsafeMountPoint, dokanOptions); var drive = new DriveInfo(DokanOperationsFixture.NormalMountPoint); var drive2 = new DriveInfo(DokanOperationsFixture.UnsafeMountPoint); while (!drive.IsReady || !drive2.IsReady) { Thread.Sleep(50); } while (DokanOperationsFixture.HasPendingFiles) { Thread.Sleep(50); } }
public Task StopAsync(CancellationToken cancellationToken) { if (!Dokan.RemoveMountPoint(_commandLineArguments.MountPoint)) { _logger.Fatal("Can't unmount {MountPoint}", _commandLineArguments.MountPoint); } return(Task.CompletedTask); }
public static void Unmount(MountableFileSystem fs) { Dokan.Unmount(Mounted[fs].Item2); string mountPoint = $"{Mounted[fs].Item2}:"; Mounted[fs].Item1.Join(); // wait for thread to actually stop Dokan.RemoveMountPoint(mountPoint); }
public static void AssemblyCleanup() { mounterThread.Abort(); mounterThread2.Abort(); Dokan.Unmount(DokanOperationsFixture.NormalMountPoint[0]); Dokan.Unmount(DokanOperationsFixture.UnsafeMountPoint[0]); Dokan.RemoveMountPoint(DokanOperationsFixture.NormalMountPoint); Dokan.RemoveMountPoint(DokanOperationsFixture.UnsafeMountPoint); }
public void Stop() { if (IsRunning) { FireStateChange(LiquesceSvcState.Unknown, "Stop has been requested"); int retVal = Dokan.DokanUnmount(mountedDriveLetter); Log.Info("Stop returned[{0}]", retVal); } }
public bool UnMountVirtualDrive() { if (_mountPoint == null) { return(false); } return(Dokan.Unmount(_mountPoint[0]) && Dokan.RemoveMountPoint(_mountPoint)); }
private static void Main(string[] args) { SetConsoleCtrlHandler(ConsoleCtrlCheck, true); var unmountOptions = new UnmountOptions(); if (CommandLine.Parser.Default.ParseArguments(args, unmountOptions)) { Dokan.RemoveMountPoint(unmountOptions.UnmountDirectory); return; } var options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { try { Console.WriteLine("DokanPbo booting..."); if (options.WriteableDirectory == null) { Console.WriteLine("Creating temporary write directory..."); options.WriteableDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); //#TODO can throw exception and die if it creates a existing folder by accident Directory.CreateDirectory(options.WriteableDirectory); //Need to register handler to catch console exit to delete directory at end SetConsoleCtrlHandler(ConsoleCtrlCheck, true); deleteTempDirOnClose = options.WriteableDirectory; } if (!Directory.Exists(options.WriteableDirectory)) { Console.WriteLine("FATAL Writeable Directory doesn't exist: " + options.WriteableDirectory); Console.ReadKey(); } ArchiveManager archiveManager = new ArchiveManager(options.PboDirectories); PboFSTree fileTree = new PboFSTree(archiveManager, options.WriteableDirectory, options.ExcludePrefix); PboFS pboFS = new PboFS(fileTree, archiveManager, options.Prefix); #if DEBUG ILogger logger = new NullLogger(); //null; #else ILogger logger = new NullLogger(); #endif Dokan.Init(); pboFS.Mount(options.MountDirectory, Program.MOUNT_OPTIONS, true, logger); Console.WriteLine("Success"); } catch (DokanException ex) { Console.WriteLine("Error: " + ex.Message); } } }
public void Unmount() { if (_th != null) { _th.Abort(); } Dokan.Unmount(this.DriveLetter); Dokan.RemoveMountPoint(this.DriveLetter + ":"); }
public static void startVDrive(char vDriveLetter) { Dokan.Unmount(vDriveLetter); di = new VDrive(); #if DEBUG Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.DebugMode, 1); }); #else Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.FixedDrive, 10); }); #endif t2.Start(); }
public virtual void ClearMountPoint() { if (!IsMounted) { return; } Dokan.RemoveMountPoint(this.MountPoint); this._isMounted = false; OnMountChanged(new connector.MountChangedArgs(_isMounted)); }
private void startVDriveToolStripMenuItem_Click(object sender, EventArgs e) { Dokan.Unmount(vDriveLetter); di = new VDrive(); #if DEBUG Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.DebugMode, 1); }); #else Thread t2 = new Thread(() => { di.Mount(vDriveLetter + ":\\", DokanOptions.FixedDrive, 10); }); #endif t2.Start(); }
public void UnmountAllDrives() { foreach (var volume in Globals.Database.Table <DiskModel>().ToList()) { var mountPoint = Globals.Database.GetMountPoint(volume.Id); try { Dokan.RemoveMountPoint(mountPoint); } catch { } // Ignored. Globals.Database.RemoveMountPoint(volume.Id); } Globals.Database.SaveSetting(WindowsUserSettings.EnableVolumeMounting, "0"); }
private bool _disposedValue; // To detect redundant calls private void Dispose(bool disposing) { if (!_disposedValue) { if (disposing) { Dokan.RemoveMountPoint(Mountpoint.FullName.Trim('\\')); } } _disposedValue = true; }
private static bool ConsoleCtrlCheck(CtrlTypes ctrlType) { if (ctrlType == CtrlTypes.CTRL_CLOSE_EVENT) { if (deleteTempDirOnClose != null) { Directory.Delete(deleteTempDirOnClose, true); } Dokan.Shutdown(); } return(true); }