|
@@ -0,0 +1,50 @@
|
|
|
+using Invercargill;
|
|
|
+
|
|
|
+namespace Ppub {
|
|
|
+
|
|
|
+ public class Index {
|
|
|
+
|
|
|
+ private const uint8[] MAGIC = { 0x50, 0x50, 0x49, 0x58, 0x00 };
|
|
|
+
|
|
|
+ private DataInputStream stream;
|
|
|
+
|
|
|
+ private int64 publication_index_position;
|
|
|
+ private int64 collection_index_position;
|
|
|
+ private int64 tag_index_position;
|
|
|
+ private int64 word_index_position;
|
|
|
+
|
|
|
+ public string get_publication_filename_by_id(uint32 id) throws Error {
|
|
|
+ lock(stream) {
|
|
|
+ stream.seek(publication_index_position + (id * 6), SeekType.SET);
|
|
|
+ var string_start = stream.read_uint32();
|
|
|
+ var string_length = stream.read_uint16();
|
|
|
+
|
|
|
+ var filename = new uint8[string_length];
|
|
|
+ stream.seek(string_start, SeekType.SET);
|
|
|
+ stream.read(filename);
|
|
|
+
|
|
|
+ return (string)filename;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public uint32[] get_collection_by_id(uint32 id) throws Error {
|
|
|
+ lock(stream) {
|
|
|
+ stream.seek(collection_index_position + (id * 6), SeekType.SET);
|
|
|
+ var collection_start = stream.read_uint32();
|
|
|
+ var collection_items = stream.read_uint16();
|
|
|
+
|
|
|
+ var publication_ids = new uint32[collection_items];
|
|
|
+ stream.seek(collection_start, SeekType.SET);
|
|
|
+ for(var i = 0; i < collection_items; i++) {
|
|
|
+ publication_ids[i] = stream.read_uint32();
|
|
|
+ }
|
|
|
+
|
|
|
+ return publication_ids;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|