Ejemplo n.º 1
0
// NewGGPKFile creates GGPKFile from afs file
func NewGGPKFile(file *afs.File, parent *record.DirectoryEntry) (ret GGPKFile) {
	ret.Record = record.FileRecord{
		NameLength: uint32(len(file.Name) + 1),
		Digest:     file.Digest,
		Name:       file.Name,
	}
	ret.Header = record.RecordHeader{
		Length: uint32(ret.Record.ByteLength()) + uint32(file.Size),
		Tag:    "FILE",
	}
	ret.Header.Length += uint32(ret.Header.ByteLength())
	ret.Parent = parent
	ret.Orig = file
	parent.Timestamp = file.Timestamp
	return

}
Ejemplo n.º 2
0
// NewGGPKDirectory creates ggpk record from afs directory
func NewGGPKDirectory(dir *afs.Directory, parent *record.DirectoryEntry) (ret GGPKDirectory) {
	ret.Record = record.DirectoryRecord{
		NameLength: uint32(len(dir.Name) + 1),
		ChildCount: uint32(len(dir.Subfolders) + len(dir.Files)),
		Digest:     dir.Digest(),
		Name:       dir.Name,
		Entries:    make([]record.DirectoryEntry, len(dir.Subfolders)+len(dir.Files)),
	}
	ret.Header = record.RecordHeader{
		Length: 0,
		Tag:    "PDIR",
	}
	ret.Header.Length = uint32(ret.Header.ByteLength() + ret.Record.ByteLength())
	ret.Parent = parent
	if parent != nil {
		parent.Timestamp = dir.Timestamp
	}

	return
}