Пример #1
0
        private PblNod LoadNod(long offset)
        {
            if (offset > reader.BaseStream.Length)
            {
                throw new PblFileException("Chyba v souboru PBL knihovny. Soubor neobsahuje všechny NOD sekce.");
            }

            reader.Seek(offset, SeekOrigin.Begin);

            // kontrola, zda se opravdu jedna o NOD sekci
            string hdr = reader.ReadBlockName();

            if (hdr != PblFile105.BLOCK_NAME_NOD)
            {
                throw new PblFileException("Chyba v souboru PBL knihovny. Nebyla nalezena NOD sekce.");
            }

            int   offset_previous = reader.ReadInt32();   // predchozi NOD
            int   offset_parent   = reader.ReadInt32();   // parent NOD ???
            int   offset_next     = reader.ReadInt32();   // nasledujici NOD
            int   unknown         = reader.ReadInt32();   // ???????
            short entries_count   = reader.ReadInt16();   // pocet ENT (entries) patricich tomuto NOD

            PblNod nod = new PblNod();

            nod.nextOffset   = offset_next;
            nod.prevOffset   = offset_previous;
            nod.parentOffset = offset_parent;
            nod.entCount     = entries_count;
            nod.offset       = offset;
            nod.entries      = new PblEntry[entries_count];

            return(nod);
        }
Пример #2
0
        private PblNod LoadNod(long offset)
        {
            if (offset > reader.BaseStream.Length)
            {
                throw new PblFileException("PBL corrupted. NOD section was not found.");
            }

            reader.Seek(offset, SeekOrigin.Begin);

            // kontrola, zda se opravdu jedna o NOD sekci
            string hdr = reader.ReadBlockName();

            if (hdr != PblFile070.BLOCK_NAME_NOD)
            {
                throw new PblFileException("PBL corrupted. ENT section was not found.");
            }

            int   offset_previous = reader.ReadInt32();   // predchozi NOD
            int   offset_parent   = reader.ReadInt32();   // parent NOD ???
            int   offset_next     = reader.ReadInt32();   // nasledujici NOD
            int   unknown         = reader.ReadInt32();   // ???????
            short entries_count   = reader.ReadInt16();   // pocet ENT (entries) patricich tomuto NOD

            PblNod nod = new PblNod();

            nod.nextOffset   = offset_next;
            nod.prevOffset   = offset_previous;
            nod.parentOffset = offset_parent;
            nod.entCount     = entries_count;
            nod.offset       = offset;
            nod.entries      = new PblEntry[entries_count];

            return(nod);
        }
Пример #3
0
        private PblNod LoadNod(long offset)
        {
            if (offset > reader.BaseStream.Length)
            {
                throw new PblFileException("PBL corrupted. NOD section was not found.");
            }

            reader.Seek(offset, SeekOrigin.Begin);

            // is it really a NOD section?
            string hdr = reader.ReadBlockName();

            if (hdr != PblFile105.BLOCK_NAME_NOD)
            {
                throw new PblFileException("PBL corrupted. ENT section was not found.");
            }

            int   offset_previous = reader.ReadInt32();   // prev NOD
            int   offset_parent   = reader.ReadInt32();   // parent NOD ???
            int   offset_next     = reader.ReadInt32();   // next NOD
            int   unknown         = reader.ReadInt32();   // ???????
            short entries_count   = reader.ReadInt16();   // ENT (entries) count in this NOD

            PblNod nod = new PblNod();

            nod.nextOffset   = offset_next;
            nod.prevOffset   = offset_previous;
            nod.parentOffset = offset_parent;
            nod.entCount     = entries_count;
            nod.offset       = offset;
            nod.entries      = new PblEntry[entries_count];

            return(nod);
        }
Пример #4
0
        private void LoadNodes()
        {
            ArrayList nods = new ArrayList();

            PblNod root = LoadNod(PblFile105.OFFSET_FIRST_NOD);

            root.parentNod = null;
            LoadNodes(nods, root, root.offset);

            this.nods = ( PblNod[] )nods.ToArray(System.Type.GetType("PowerDoc.PblNod"));
        }
Пример #5
0
        private PblNod LoadNodes(ArrayList nods, PblNod root, long offset)
        {
            PblNod nod = LoadNod(offset);

            nod.parentNod = root;
            nods.Add(nod);
            if (nod.nextOffset != 0)
            {
                nod.leftNod = LoadNodes(nods, nod, nod.nextOffset);
            }
            if (nod.prevOffset != 0)
            {
                nod.rightNod = LoadNodes(nods, nod, nod.prevOffset);
            }

            return(nod);
        }
Пример #6
0
        private void LoadEntries(PblNod nod)
        {
            reader.Seek(nod.offset, SeekOrigin.Begin);
            string hdr = reader.ReadBlockName();

            if (hdr != PblFile105.BLOCK_NAME_NOD)
            {
                throw new PblFileException("Chyba v souboru PBL knihovny. Nebyla nalezena NOD sekce.");
            }

            reader.Seek(OFFSET_FIRST_ENT, SeekOrigin.Current);

            for (int i = 0; i < nod.entCount; i++)
            {
                long offset = reader.Position;
                hdr = reader.ReadBlockName();
                if (hdr != PblFile105.BLOCK_NAME_ENT)
                {
                    throw new PblFileException("Chyba v souboru PBL knihovny. Nebyla nalezena ENT sekce.");
                }

                string   unknown         = reader.ReadUnicodeString(4);
                long     dat_offset      = reader.ReadInt32();
                int      entry_size      = reader.ReadInt32();
                DateTime dt              = reader.ReadDateTime();
                short    comments_length = reader.ReadInt16();
                short    name_length     = reader.ReadInt16();
                string   name            = reader.ReadUnicodeString(name_length / 2);

                PblEntry ent = new PblEntry();
                ent.offset         = offset;
                ent.dataOffset     = dat_offset;
                ent.size           = entry_size;
                ent.time           = dt;
                ent.commentsLength = comments_length;
                ent.name           = name;
                nod.entries[i]     = ent;
                this.entries.Add(ent.name, ent);
            }
        }