~rbn/neinp

ref: f0b91981560c6d7f112692b0479d8d28cc062ba7 neinp/message/remove.go -rw-r--r-- 1019 bytes
f0b91981Ruben Schuller add build badge 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package message // import "go.rbn.im/neinp/message"

import (
	"go.rbn.im/neinp/basic"
	"go.rbn.im/neinp/fid"
	"io"
)

/*TRemove signals the server to remove the file and clunk the Fid.

The Fid is clunked even if the remove fails. The request will fail
if the client doesn't have the permission to write the parent directory.

See also: http://man.cat-v.org/inferno/5/remove
*/
type TRemove struct {
	Fid fid.Fid
}

func (m *TRemove) encode(w io.Writer) (int64, error) {
	n, err := basic.Uint32Encode(w, uint32(m.Fid))
	if err != nil {
		return n, err
	}

	return n, nil
}

func (m *TRemove) decode(r io.Reader) (int64, error) {
	f, n, err := basic.Uint32Decode(r)
	if err != nil {
		return n, err
	}

	m.Fid = fid.Fid(f)
	return n, nil
}

/*RRemove is the answer for a successful TRemove request.

See also: http://man.cat-v.org/inferno/5/remove
*/
type RRemove struct{}

func (m *RRemove) encode(w io.Writer) (int64, error) {
	return 0, nil
}

func (m *RRemove) decode(r io.Reader) (int64, error) {
	return 0, nil
}