~rbn/neinp

ref: b441da6dea2e963387a86b9d1d57802b77f21b83 neinp/message/remove.go -rw-r--r-- 995 bytes
b441da6dRuben Schuller initial commit 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 (
	"github.com/rbns/neinp/basic"
	"github.com/rbns/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
}