MCPcopy
hub / github.com/qax-os/excelize / write

Method write

crypt.go:961–1022  ·  view source on GitHub ↗

write provides a function to create compound file package stream.

()

Source from the content-addressed store, hash-verified

959
960// write provides a function to create compound file package stream.
961func (c *cfb) write() []byte {
962 c.prepare()
963 location := c.locate()
964 c.stream = make([]byte, location[7]<<9)
965 var i, j int
966 for i = 0; i < 8; i++ {
967 c.writeBytes([]byte{oleIdentifier[i]})
968 }
969 c.writeBytes(make([]byte, 16))
970 c.writeUint16(0x003E)
971 c.writeUint16(0x0003)
972 c.writeUint16(0xFFFE)
973 c.writeUint16(0x0009)
974 c.writeUint16(0x0006)
975 c.writeBytes(make([]byte, 10))
976 c.writeUint32(location[2])
977 c.writeUint32(location[0] + location[1] + location[2] + location[3] - 1)
978 c.writeUint32(0)
979 c.writeUint32(1 << 12)
980 if location[3] != 0 {
981 c.writeUint32(location[0] + location[1] + location[2] - 1)
982 } else {
983 c.writeUint32(endOfChain)
984 }
985 c.writeUint32(location[3])
986 if location[1] != 0 {
987 c.writeUint32(location[0] - 1)
988 } else {
989 c.writeUint32(endOfChain)
990 }
991 c.writeUint32(location[1])
992 c.writeMSAT(location)
993 sector := c.writeSectorChains(location)
994 c.writeDirectoryEntry(location)
995 for i = 1; i < len(c.sectors); i++ {
996 sector = c.sectors[i]
997 if sector.size >= 0x1000 {
998 c.position = (sector.start + 1) << 9
999 for j = 0; j < sector.size; j++ {
1000 c.writeBytes([]byte{sector.content[j]})
1001 }
1002 for ; j&0x1FF != 0; j++ {
1003 c.writeBytes([]byte{0})
1004 }
1005 }
1006 }
1007 for i = 1; i < len(c.sectors); i++ {
1008 sector = c.sectors[i]
1009 if sector.size > 0 && sector.size < 0x1000 {
1010 for j = 0; j < sector.size; j++ {
1011 c.writeBytes([]byte{sector.content[j]})
1012 }
1013 for ; j&0x3F != 0; j++ {
1014 c.writeBytes([]byte{0})
1015 }
1016 }
1017 }
1018 for c.position < len(c.stream) {

Callers 2

TestEncryptFunction · 0.95
EncryptFunction · 0.95

Calls 8

prepareMethod · 0.95
locateMethod · 0.95
writeBytesMethod · 0.95
writeUint16Method · 0.95
writeUint32Method · 0.95
writeMSATMethod · 0.95
writeSectorChainsMethod · 0.95
writeDirectoryEntryMethod · 0.95

Tested by 1

TestEncryptFunction · 0.76