Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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();}
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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;  
            }

        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
0
        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);
                }
            }
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public Task StopAsync(CancellationToken cancellationToken)
 {
     if (!Dokan.RemoveMountPoint(_commandLineArguments.MountPoint))
     {
         _logger.Fatal("Can't unmount {MountPoint}", _commandLineArguments.MountPoint);
     }
     return(Task.CompletedTask);
 }
Exemplo n.º 12
0
        public bool UnMountVirtualDrive()
        {
            if (_mountPoint == null)
            {
                return(false);
            }

            return(Dokan.Unmount(_mountPoint[0]) && Dokan.RemoveMountPoint(_mountPoint));
        }
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
        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);
                }
            }
        }
Exemplo n.º 15
0
        public void Unmount()
        {
            if (_th != null)
            {
                _th.Abort();
            }

            Dokan.Unmount(this.DriveLetter);
            Dokan.RemoveMountPoint(this.DriveLetter + ":");
        }
Exemplo n.º 16
0
        public virtual void ClearMountPoint()
        {
            if (!IsMounted)
            {
                return;
            }

            Dokan.RemoveMountPoint(this.MountPoint);
            this._isMounted = false;
            OnMountChanged(new connector.MountChangedArgs(_isMounted));
        }
Exemplo n.º 17
0
        private bool _disposedValue; // To detect redundant calls

        private void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    Dokan.RemoveMountPoint(Mountpoint.FullName.Trim('\\'));
                }
            }

            _disposedValue = true;
        }
Exemplo n.º 18
0
        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");
        }
Exemplo n.º 19
0
 public static void End()
 {
     try
     {
         Dokan.Unmount(Properties.Settings.Default.MountPoint[0]);
         Dokan.RemoveMountPoint(Properties.Settings.Default.MountPoint + ":\\");
     }
     catch (Exception)
     {
         // ignored
     }
 }
Exemplo n.º 20
0
        public void UnmountNetworkDrive(Guid cloudId)
        {
            var mountPoint = Globals.Database.GetMountPoint(cloudId);

            try { Dokan.RemoveMountPoint(mountPoint); }
            catch { } // Ignored.

            Globals.Database.RemoveMountPoint(cloudId);
            if (Globals.Volumes.TryRemove(cloudId, out var thread))
            {
                thread.Dispose();
            }
        }
Exemplo n.º 21
0
        public void Dispose()
        {
            Debug.WriteLine("Dispose");

            try
            {
                Dokan.RemoveMountPoint(String.Format("{0}:\\", Letter));
            }
            catch
            {
                Status = DriveStatus.Unmounted;
            }
            finally
            {
                _filesystem = null;
            }
        }
Exemplo n.º 22
0
        public void PlayStream()
        {
            string mount_point = System.IO.Path.Combine(GClass88.DirectoryCache, "streaming", System.IO.Path.GetRandomFileName());

            System.IO.Directory.CreateDirectory(mount_point);
            Class17 fs = new Class17(this.CurrentGamePath, this.gclass30_0);

            Task.Run((Action)(() => fs.Mount(mount_point, DokanOptions.WriteProtection, 1, (ILogger)null)));
            Thread.Sleep(3000);
            this._overriddenGamePath = mount_point;
            this.InternaPrelPlay();
            this.Event_0 += (EventHandler)((sender, e) =>
            {
                fs.method_1();
                Dokan.RemoveMountPoint(mount_point);
            });
            this.method_8(this.GetArguments());
        }
Exemplo n.º 23
0
        public void Initialize()
        {
            DokanOperations mirror = new DokanOperations(_BasePath, _MinePath);

            Task.Factory.StartNew(() => {
                mirror.Mount(_WorkerPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI, 1, new NullLogger());
            });

            Watcher watcher = new Watcher(_MinePath);

            watcher.Change += OnWatcherOnChange;
            watcher.EnableRaisingEvents = true;


            Console.WriteLine(@"STOP");
            Console.ReadLine();

            Dokan.RemoveMountPoint(_WorkerPath);
            Directory.Delete(_WorkerPath);
        }
Exemplo n.º 24
0
        private static void Main()
        {
            // reset client
            if (Directory.Exists(MinePath))
            {
                Directory.Delete(MinePath, true);
            }

            Directory.CreateDirectory(MinePath);

            if (Directory.Exists(BasePath))
            {
                Directory.Delete(BasePath, true);
            }
            Directory.CreateDirectory(BasePath);

            // download
            _Ftp = new FtpClient("127.0.0.1", "test", "test");
            _Ftp.DownloadDirectoryAsync("/", MinePath).Wait();

            // start dokan
            Directory.CreateDirectory(MountPath);
            DokanOperations dokanOperations = new DokanOperations(MinePath);

            dokanOperations.BeforeWriteFile += DokanOperationsOnBeforeWriteFile;
            dokanOperations.AfterWriteFile  += DokanOperationsOnAfterWriteFile;
            dokanOperations.BeforeReadFile  += DokanOperationsOnBeforeReadFile;
            Task.Factory.StartNew(() => { dokanOperations.Mount(MountPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI, 1); });

            string line;

            do
            {
                line = Console.ReadLine();
                Console.Clear();
            } while (line != "q");

            // cleanup
            Dokan.RemoveMountPoint(MountPath);
            Directory.Delete(MountPath);
        }
Exemplo n.º 25
0
        private void Unmount()
        {
            if (opt != null && sshfs != null)
            {
                Debug.WriteLine(string.Format("SSHFS Trying unmount : {0}", mountPoint));

                try
                {
                    Dokan.RemoveMountPoint(mountPoint);
                    Debug.WriteLine("DokanReveMountPoint success\n");
                }
                catch (DokanException ex)
                {
                    Debug.WriteLine("DokanRemoveMountPoint failed: " + ex.Message + "\n");
                }
                // This should be called from Dokan, but not called.
                // Call here explicitly.
                sshfs.Unmounted(null);
            }
            unmount.Visible = false;
            mount.Visible   = true;
        }
Exemplo n.º 26
0
        public void Unmount()
        {
            _threadCancel?.Cancel();
            _pauseEvent?.Set();

            Debug.WriteLine("Unmount");

            Status = DriveStatus.Unmounting;
            try
            {
                Dokan.RemoveMountPoint($"{mountedLetter}:\\");
            }
            catch
            {
                //Status = DriveStatus.Unmounted;
                //  OnStatusChanged(EventArgs.Empty);
            }
            finally
            {
                _filesystem = null;
            }
        }
Exemplo n.º 27
0
        private void Unmount(string mountPoint)
        {
            log.Info(String.Format("Unmount {0}", mountPoint));

            try
            {
                Dokan.RemoveMountPoint(mountPoint);
                driver.Unmount(null);
                driver = null;
            }
            catch (DokanException ex)
            {
                log.Error("Unmount failed", ex);
            }

            if (dokanThrd != null && dokanThrd.IsAlive)
            {
                log.Info("Dokan thread join");
                dokanThrd.Join();
            }
            dokanThrd = null;
            log.Info("Dokan thread ended");
        }
Exemplo n.º 28
0
 public void Unmount(string mountPoint)
 {
     Dokan.RemoveMountPoint(mountPoint);
     this.fsTree = null;
 }
Exemplo n.º 29
0
 public static void AssemblyCleanup()
 {
     mounterThread.Abort();
     Dokan.Unmount(DokanOperationsFixture.MOUNT_POINT[0]);
     Dokan.RemoveMountPoint(DokanOperationsFixture.MOUNT_POINT.ToString(CultureInfo.InvariantCulture));
 }
Exemplo n.º 30
0
 public void Dispose()
 {
     //_mounterThread.Abort();
     Dokan.Unmount(MOUNT_POINT[0]);
     Dokan.RemoveMountPoint(MOUNT_POINT);
 }