Exemplo n.º 1
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.º 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);
                }
            }
        }