~rbn/neinp

ref: 280ca11dc4f314d4bb506de2f219eb70dd959227 neinp/message/remove.go -rw-r--r-- 993 bytes
280ca11dRuben Schuller update go.mod 1 year, 2 months 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 (
	"git.sr.ht/~rbn/neinp/basic"
	"git.sr.ht/~rbn/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
}