diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2021-07-28 18:21:52 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2021-07-28 14:21:52 -0700 |
| commit | 22c599abc18895f73e96095f35b71cf3357d41b4 (patch) | |
| tree | 482ef57d386c955692ea43c43e4655b3c3763499 /file_header.go | |
| parent | 71c56068adca18f76ebee86355f000a3e51d3127 (diff) | |
Move code to hotline dir
Diffstat (limited to 'file_header.go')
| -rw-r--r-- | file_header.go | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/file_header.go b/file_header.go deleted file mode 100644 index 60c652e..0000000 --- a/file_header.go +++ /dev/null @@ -1,36 +0,0 @@ -package hotline - -import ( - "encoding/binary" - "github.com/jhalter/mobius/concat" -) - -type FileHeader struct { - Size []byte // Total size of FileHeader payload - Type []byte // 0 for file, 1 for dir - FilePath []byte // encoded file path -} - -func NewFileHeader(fileName string, isDir bool) FileHeader { - fh := FileHeader{ - Size: make([]byte, 2), - Type: []byte{0x00, 0x00}, - FilePath: EncodeFilePath(fileName), - } - if isDir { - fh.Type = []byte{0x00, 0x01} - } - - encodedPathLen := uint16(len(fh.FilePath) + len(fh.Type)) - binary.BigEndian.PutUint16(fh.Size, encodedPathLen) - - return fh -} - -func (fh *FileHeader) Payload() []byte { - return concat.Slices( - fh.Size, - fh.Type, - fh.FilePath, - ) -} |