Beispiel #1
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
}
Beispiel #2
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"))
	}
}