Exemple #1
0
func (h *dbFileHeader) Unserialize(r io.Reader) {
	core.ReadUint32(r, &h.filetype)
	core.ReadUint32(r, &h.version)
	if h.version != dbVersion {
		panic(errors.New("Invalid version in dbFileHeader"))
	}
	h.datasetName.Unserialize(r)
}
Exemple #2
0
func (b *DirectoryBlock) Unserialize(r io.Reader) (size int) {
	var check uint32
	size += core.ReadUint32(r, &check)
	if check != 0x64626C6B { // "dblk"
		panic(errors.New("Corrupted DirectoryBlock!"))
	}
	var l uint32
	size += core.ReadUint32(r, &l)
	b.File = make([]*FileEntry, l)
	for i := range b.File {
		b.File[i] = new(FileEntry)
		size += b.File[i].Unserialize(r)
	}
	return
}
Exemple #3
0
func (b *FileChainBlock) Unserialize(r io.Reader) (size int) {
	var check uint32
	size += core.ReadUint32(r, &check)
	if check != 0x6663686E { // "fchn"
		panic(errors.New("Corrupted FileChainBlock!"))
	}
	var l uint32
	size += core.ReadUint32(r, &l)
	b.ChainBlocks = make([]core.Byte128, l)
	b.DecryptKeys = make([]core.Byte128, l)
	for i := range b.ChainBlocks {
		size += b.ChainBlocks[i].Unserialize(r)
		size += b.DecryptKeys[i].Unserialize(r)
	}
	return
}
Exemple #4
0
func (e *FileEntry) Unserialize(r io.Reader) (size int) {
	var check uint32
	size += core.ReadUint32(r, &check)
	if check != 0x66656E74 { // "fent"
		panic(errors.New("Corrupted FileEntry!"))
	}
	size += e.FileName.Unserialize(r)
	size += core.ReadInt64(r, &e.FileSize)
	size += core.ReadUint32(r, &e.FileMode)
	size += core.ReadInt64(r, &e.ModTime)
	size += e.ReferenceID.Unserialize(r)

	size += core.ReadUint8(r, &e.ContentType)
	if e.HasContentBlockID() {
		size += e.ContentBlockID.Unserialize(r)
	}
	if e.HasDecryptKey() {
		size += e.DecryptKey.Unserialize(r)
	}
	if e.HasFileLink() {
		size += e.FileLink.Unserialize(r)
	}
	return size
}
Exemple #5
0
func (t *dbTx) Unserialize(r io.Reader) {
	core.ReadInt64(r, &t.timestamp)
	core.ReadUint32(r, &t.txType)
	switch t.txType {
	case dbTxTypeAdd:
		var s core.DatasetState
		s.Unserialize(r)
		t.data = s
	case dbTxTypeDel:
		var s core.Byte128
		s.Unserialize(r)
		t.data = s
	default:
		panic(errors.New("Corrupt transaction file"))
	}
}