Пример #1
0
        public int CompareTo(object obj)
        {
            if (obj is NintendoU8Directory)
            {
                NintendoU8Directory o = (NintendoU8Directory)obj;

                return(this.DirectoryName.CompareTo(o.DirectoryName));
            }

            throw new ArgumentException("object is not a NintendoU8Directory");
        }
Пример #2
0
        private NintendoU8Directory getDirectoryNode(FileStream fs, int nodeIndex,
                                                     string parentDirectory, out int lastIndexProcessed)
        {
            string newParentDirectoryName;
            uint   maxNodeIndex;
            NintendoU8Directory newSubDirectory;

            lastIndexProcessed = nodeIndex;

            // get node
            u8Node node = this.NodeList[nodeIndex];

            // get directory name
            string directoryName = ParseFile.ReadAsciiString(fs, this.NameTableOffset + node.NameOffset);

            // create directory item
            NintendoU8Directory newDirectory = new NintendoU8Directory(this.SourceFileName, directoryName, parentDirectory);

            // parse other items
            maxNodeIndex = node.DataSize;


            for (int i = (nodeIndex + 1); i < maxNodeIndex; i = (lastIndexProcessed + 1))
            {
                node = this.NodeList[i];
                newParentDirectoryName = Path.Combine(parentDirectory, directoryName);

                if (node.IsDirectory())
                {
                    newSubDirectory = this.getDirectoryNode(fs, i, newParentDirectoryName, out lastIndexProcessed);

                    if (!newSubDirectory.DirectoryName.Equals("."))
                    {
                        newDirectory.SubDirectoryArray.Add(newSubDirectory);
                    }
                    else // in current folder "."
                    {
                        // move folders to this folder
                        foreach (NintendoU8Directory d in newSubDirectory.SubDirectories)
                        {
                            newDirectory.SubDirectoryArray.Add(d);
                        }

                        // move files to this folder
                        foreach (NintendoU8File f in newSubDirectory.Files)
                        {
                            newDirectory.FileArray.Add(f);
                        }
                    }
                }
                else
                {
                    newDirectory.FileArray.Add(this.getFileNode(fs, i, newParentDirectoryName));
                    lastIndexProcessed = i;
                }
            }



            return(newDirectory);
        }