Пример #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);
                }
            }
        }
Пример #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);
                }
            }
        }
Пример #3
0
        public System.IO.Stream GetDebinarizedStream(byte[] buffer)
        {
            if (debinarizedStream != null)
            {
                return(debinarizedStream);
            }

            var derapStream = PboFS.DeRapConfig(base.GetFileStream(), base.Filesize, buffer);

            debinarizedStream      = derapStream;
            FileInformation.Length = derapStream.Length;
            return(derapStream);
        }
Пример #4
0
        private void CreateFileTree()
        {
            this.root           = new PboFsRealFolder(null, writeableDirectory, null);
            this.fileTreeLookup = new HashSet <IPboFsNode>();
            this.fileTreeLookup.Add(this.root);
            var hasCfgConvert = PboFS.HasCfgConvert();

            foreach (string filePath in this.archiveManager.FilePathToFileEntry.Keys)
            {
                if (excludePrefix != null && filePath.StartsWith(excludePrefix))
                {
                    continue;
                }
                FileEntry file = this.archiveManager.FilePathToFileEntry[filePath];

                PboFsFolder currentFolder = root;
                var         currentPath   = "\\";
                var         splitPath     = filePath.Split('\\');

                // Create inputFolder for all sub paths
                for (int i = 1; i < splitPath.Length - 1; i++)
                {
                    var folderName = splitPath[i];
                    currentPath += folderName;

                    PboFsFolder folder = null;
                    if (!this.fileTreeLookup.Contains(new PboFsLookupDummy(currentPath)))
                    {
                        folder = new PboFsFolder(folderName, currentFolder);
                        this.fileTreeLookup.Add(folder);
                    }
                    else
                    {
                        fileTreeLookup.TryGetValue(new PboFsLookupDummy(currentPath), out var node);
                        folder = node as PboFsFolder;
                    }

                    if (!currentFolder.Children.ContainsKey(folderName))
                    {
                        currentFolder.Children[folderName] = currentFolder = folder;
                    }
                    else
                    {
                        currentFolder = (PboFsFolder)currentFolder.Children[folderName];
                    }

                    currentPath += "\\";
                }

                var fileName = splitPath[splitPath.Length - 1];
                var fileNode = new PboFsFile(fileName, file, currentFolder);
                currentFolder.Children[fileName] = fileNode;
                this.fileTreeLookup.Add(fileNode);
                if (hasCfgConvert && fileName == "config.bin")
                {
                    var derapNode = new PboFsDebinarizedFile("config.cpp", file, currentFolder);
                    currentFolder.Children["config.cpp"] = derapNode;
                    this.fileTreeLookup.Add(derapNode);
                }
            }

            //Interweave writeableDirectory
            LinkRealDirectory(new System.IO.DirectoryInfo(writeableDirectory), "", this.root, true);
        }
Пример #5
0
        private void CreateFileTree()
        {
            this.root           = new PboFsRealFolder(null, writeableDirectory, null);
            this.fileTreeLookup = new HashSet <IPboFsNode>();
            this.fileTreeLookup.Add(this.root);
            var hasCfgConvert = PboFS.HasCfgConvert();


            foreach (var(filePath, file) in this.archiveManager.Enumerator)
            {
                if (excludePrefix != null && filePath.StartsWith(excludePrefix))
                {
                    continue;
                }
                this.archiveManager.TotalBytes += (long)file.DataSize;

                PboFsFolder currentFolder = root;
                var         currentPath   = "\\";
                var         splitPath     = filePath.Split(PboFsLookupDummy.PathChars, StringSplitOptions.RemoveEmptyEntries);

                // Make sure the files directory path exists
                for (int i = 0; i < splitPath.Length - 1; i++)
                {
                    var folderName = splitPath[i];
                    currentPath += folderName;

                    //A part of the path might already exist, walking the tree directly via this shortcut saves alot of time
                    currentFolder.Children.TryGetValue(folderName, out var subFolderNode);
                    if (subFolderNode is PboFsFolder subFolder)
                    {
                        currentFolder = subFolder;
                        currentPath  += "\\";
                        continue;
                    }
                    var lookup = new PboFsLookupDummy(currentPath);

                    PboFsFolder folder = null;
                    if (!this.fileTreeLookup.Contains(lookup))
                    {
                        folder = new PboFsFolder(folderName, currentFolder);
                        this.fileTreeLookup.Add(folder);
                    }
                    else
                    {
                        fileTreeLookup.TryGetValue(lookup, out var node);
                        folder = node as PboFsFolder;
                    }

                    if (!currentFolder.Children.ContainsKey(folderName))
                    {
                        currentFolder.Children[folderName] = currentFolder = folder;
                    }
                    else
                    {
                        currentFolder = (PboFsFolder)currentFolder.Children[folderName];
                    }

                    currentPath += "\\";
                }

                var fileName = splitPath[splitPath.Length - 1];
                var fileNode = new PboFsFile(fileName, file, currentFolder);

                if (hasCfgConvert && fileName.EndsWith("rvmat"))
                {
                    byte[] buffer = new byte[4];
                    fileNode.ReadFile(buffer, out var length, 0);
                    if (buffer[0] == 0 && buffer[1] == 'r' && buffer[2] == 'a' && buffer[3] == 'P')
                    {
                        var derapNode = new PboFsDebinarizedFile(fileName, file, currentFolder);
                        currentFolder.Children[fileName] = derapNode;
                        this.fileTreeLookup.Add(derapNode);
                        continue;
                    }
                }

                currentFolder.Children[fileName] = fileNode;
                this.fileTreeLookup.Add(fileNode);

                if (hasCfgConvert && fileName == "config.bin")
                {
                    var derapNode = new PboFsDebinarizedFile("config.cpp", file, currentFolder);
                    currentFolder.Children["config.cpp"] = derapNode;
                    this.fileTreeLookup.Add(derapNode);
                }
            }

            //Interweave writeableDirectory
            LinkRealDirectory(new System.IO.DirectoryInfo(writeableDirectory), "", this.root, true);
        }