コード例 #1
0
        public static FolderPointer FromReader(BinaryReader reader)
        {
            var ret = new FolderPointer();

            ret.NameOffset  = reader.ReadUInt32();
            ret.FolderBlock = reader.ReadInt32();
            return(ret);
        }
コード例 #2
0
ファイル: FolderEntry.cs プロジェクト: ahoiahoi/Nexus.Archive
        public FolderEntry(string name, IndexFile indexFile, BinaryReader reader)
        {
            _index = indexFile;
            Path   = name;
            _lazyChildrenReader = new Lazy <List <IArchiveFilesystemEntry> >(ReadChildren, false);
            Subdirectories      = reader.ReadInt32();
            Files = reader.ReadInt32();
            var dataSize     = FolderPointer.Size * Subdirectories + FileEntry.Size * Files + 8;
            var stringLength = reader.BaseStream.Length - dataSize;

            _folderPointers = new FolderPointer[Subdirectories];
            _files          = new FileEntry[Files];
            for (var x = 0; x < Subdirectories; x++)
            {
                _folderPointers[x] = FolderPointer.FromReader(reader);
            }

            for (var x = 0; x < Files; x++)
            {
                _files[x] = FileEntry.FromReader(reader);
                if (((int)_files[x].Flags & 1) != 1)
                {
                    Debugger.Break();
                }
            }

            string ReadName(int itemNameOffset)
            {
                reader.BaseStream.Seek(dataSize + itemNameOffset, SeekOrigin.Begin);
                var  nameBuilder = new StringBuilder();
                char next;

                while ((next = reader.ReadChar()) != '\0')
                {
                    nameBuilder.Append(next);
                }

                return(nameBuilder.ToString());
            }

            foreach (var folder in _folderPointers)
            {
                folder.Name = GetChildPath(ReadName((int)folder.NameOffset));
            }

            foreach (var file in _files)
            {
                file.Path = GetChildPath(ReadName(file.NameOffset));
            }
            //var nameData = reader.ReadBytes((int)nameLength);
        }