Implemented some other InMessage methods.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 14:55:35 +10:00
parent e0d989cba3
commit b550b092fe
1 changed files with 18 additions and 4 deletions

View File

@ -63,17 +63,31 @@ func (m *InMessage) Header() (h *fusekernel.InHeader) {
// Return the number of bytes left to consume.
func (m *InMessage) Len() uintptr {
panic("TODO")
return uintptr(len(m.remaining))
}
// Consume the next n bytes from the message, returning a nil pointer if there
// are fewer than n bytes available.
func (m *InMessage) Consume(n uintptr) (p unsafe.Pointer) {
panic("TODO")
if m.Len() == 0 || n > m.Len() {
return
}
p = unsafe.Pointer(&m.remaining[0])
m.remaining = m.remaining[n:]
return
}
// Equivalent to Consume, except returns a slice of bytes. The result will be
// nil if Consume fails.
// nil if Consume would fail.
func (m *InMessage) ConsumeBytes(n uintptr) (b []byte) {
panic("TODO")
if n > m.Len() {
return
}
b = m.remaining[:n]
m.remaining = m.remaining[n:]
return
}