Exemple #1
0
        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);
            }
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
0
 private static void Main()
 {
     try
     {
         var rfs = new RFS();
         Dokan.Init();
         rfs.Mount("r:\\", DokanOptions.DebugMode | DokanOptions.StderrOutput);
         Dokan.Shutdown();
         Console.WriteLine(@"Success");
     }
     catch (DokanException ex)
     {
         Console.WriteLine(@"Error: " + ex.Message);
     }
 }
Exemple #4
0
        private static void Main(string[] args)
        {
            try
            {
                var arguments = args
                                .Select(x => x.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries))
                                .ToDictionary(x => x[0], x => x.Length > 1 ? x[1] as object : true, StringComparer.OrdinalIgnoreCase);

                var mirrorPath = arguments.ContainsKey(MirrorKey)
                   ? arguments[MirrorKey] as string
                   : @"C:\";

                var mountPath = arguments.ContainsKey(MountKey)
                   ? arguments[MountKey] as string
                   : @"N:\";

                var unsafeReadWrite = arguments.ContainsKey(UseUnsafeKey);

                Console.WriteLine($"Using unsafe methods: {unsafeReadWrite}");
                var mirror = unsafeReadWrite
                    ? new UnsafeMirror(mirrorPath)
                    : new Mirror(mirrorPath);

                Dokan.Init();

                using (DokanInstance dokanInstance = mirror.CreateFileSystem(mountPath, DokanOptions.DebugMode | DokanOptions.EnableNotificationAPI))
                {
                    var notify = new Notify();
                    notify.Start(mirrorPath, mountPath, dokanInstance);
                    dokanInstance.WaitForFileSystemClosed(uint.MaxValue);
                }

                Dokan.Shutdown();

                Console.WriteLine(@"Success");
            }
            catch (DokanException ex)
            {
                Console.WriteLine(@"Error: " + ex.Message);
            }
        }