Beispiel #1
0
        private DirectoryEntry ReadDirectoryEntry(long Offset)
        {
            zimFileBinaryReader.BaseStream.Seek (Offset, SeekOrigin.Begin);
            DirectoryEntry deOutput = new DirectoryEntry ();
            deOutput.MimeType = zimFileBinaryReader.ReadInt16 ();
            deOutput.ParameterLength = zimFileBinaryReader.ReadByte ();
            deOutput.Namespace = (UrlNamespace) zimFileBinaryReader.ReadByte ();
            deOutput.Revision = zimFileBinaryReader.ReadInt32 ();

            switch (deOutput.EntryType) {

            case DirectoryEntry.DirectoryEntryType.Article:
                deOutput.Cluster = zimFileBinaryReader.ReadInt32 ();
                deOutput.Blob = zimFileBinaryReader.ReadInt32 ();
                deOutput.Url = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Title = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Parameters.AddRange (zimFileBinaryReader.ReadBytes(deOutput.ParameterLength));
                break;

            case DirectoryEntry.DirectoryEntryType.Redirect:
                deOutput.Cluster = zimFileBinaryReader.ReadInt32 ();
                deOutput.Url = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Title = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Parameters.AddRange (zimFileBinaryReader.ReadBytes(deOutput.ParameterLength));
                break;

            case DirectoryEntry.DirectoryEntryType.LinkTarget:
                goto case DirectoryEntry.DirectoryEntryType.DeletedArticle;
            case DirectoryEntry.DirectoryEntryType.DeletedArticle:
                zimFileBinaryReader.BaseStream.Seek (8, SeekOrigin.Current);
                deOutput.Url = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Title = zimFileBinaryReader.ReadNullTerminatedString ();
                deOutput.Parameters.AddRange (zimFileBinaryReader.ReadBytes(deOutput.ParameterLength));
                break;

            }

            return deOutput;
        }
Beispiel #2
0
        private Article GetArticle(DirectoryEntry DE)
        {
            Article A = new Article ();
            A.DirectoryEntry = DE;

            ArticleCluster AC = GetArticleCluster (DE.Cluster);
            A.Body = AC.Blobs[DE.Blob];
            return A;
        }