Esempio n. 1
0
        /// <summary>
        /// Find the record with a <paramref name="path"/>
        /// </summary>
        /// <param name="path">Path in GGPK under <paramref name="parent"/></param>
        /// <param name="parent">Where to start searching, null for ROOT directory in GGPK</param>
        /// <returns>null if not found</returns>
        public virtual RecordTreeNode FindRecord(string path, RecordTreeNode parent = null)
        {
            parent ??= rootDirectory;
            var SplittedPath = path.Split('/', '\\');

            foreach (var name in SplittedPath)
            {
                var next = parent.GetChildItem(name);
                if (next == null)
                {
                    return(null);
                }
                parent = next;
            }
            return(parent);
        }
Esempio n. 2
0
        /// <summary>
        /// Find the record with a <paramref name="path"/>
        /// <param name="path">Path in GGPK from <paramref name="parent"/></param>
        /// <param name="parent">null for ROOT directory in GGPK</param>
        /// </summary>
        public virtual RecordTreeNode FindRecord(string path, RecordTreeNode parent = null)
        {
            var SplittedPath = Regex.Replace(path, @"^ROOT(/|\\)", "").Split('/', '\\');

            parent ??= rootDirectory;
            foreach (var name in SplittedPath)
            {
                var next = parent.GetChildItem(name);
                if (next == null)
                {
                    return(null);
                }
                parent = next;
            }
            return(parent);
        }
Esempio n. 3
0
        public virtual void BuildBundleTree(LibBundle.Records.FileRecord fr, RecordTreeNode parent)
        {
            var SplittedPath = fr.path.Split('/');
            var path         = "";

            for (var i = 0; i < SplittedPath.Length; i++)
            {
                var name         = SplittedPath[i];
                var isFile       = (i + 1 == SplittedPath.Length);
                var parentOfFile = (i + 2 == SplittedPath.Length);
                var next         = parent.GetChildItem(name);
                path += name;
                if (!isFile)
                {
                    path += "/";
                }
                if (next == null)
                { // No exist node, Build a new node
                    if (isFile)
                    {
                        next = new BundleFileNode(name, fr, this);
                    }
                    else if (parentOfFile)
                    {
                        next = new BundleDirectoryNode(name, path, fr.parent.NameHash, fr.parent.Offset, fr.parent.Size, this);
                    }
                    else
                    {
                        next = new BundleDirectoryNode(name, path, 0, 0, 0, this);
                    }
                    parent.Children.Add(next);
                    next.Parent = parent;
                }
                else if (parentOfFile && next.Offset == 0)
                {
                    ((BundleDirectoryNode)next).Hash = fr.parent.NameHash;
                    next.Offset = fr.parent.Offset;
                    next.Length = fr.parent.Size;
                }
                parent = next;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Find the record with a <paramref name="path"/>
        /// </summary>
        public RecordTreeNode FindRecord(string path, RecordTreeNode parent = null)
        {
            var SplittedPath = path.Split(new char[] { '/', '\\' });

            if (parent == null)
            {
                parent = rootDirectory;
            }
            for (int i = 0; i < SplittedPath.Length; i++)
            {
                var name = SplittedPath[i];
                var next = parent.GetChildItem(name);
                if (next == null)
                {
                    return(null);
                }
                parent = next;
            }
            return(parent);
        }