package bx import ( "bytes" "encoding/binary" ) type CmdDeleteFile struct { baseBxCmd files []string } func NewCmdDeleteFile(files []string) CmdDeleteFile { return CmdDeleteFile{ baseBxCmd: newBaseCmd(CMD_DEL_FILE.group, CMD_DEL_FILE.code), files: files, } } func (cmd CmdDeleteFile) Build() []byte { w := bytes.NewBuffer(make([]byte, 0, 1024)) binary.Write(w, binary.LittleEndian, cmd.Group()) binary.Write(w, binary.LittleEndian, cmd.Cmd()) binary.Write(w, binary.LittleEndian, cmd.ReqResp()) binary.Write(w, binary.LittleEndian, []byte{0x00, 0x00}) l := uint16(len(cmd.files)) if l != 0 { binary.Write(w, binary.LittleEndian, l) for _, v := range cmd.files { binary.Write(w, binary.BigEndian, []byte(v)) } return w.Bytes() } binary.Write(w, binary.LittleEndian, []byte{0x00}) return w.Bytes() }