blob: ddcb6da262a979e15b3f1fb51ab24f7310b6d12f (
plain)
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
|
package main
import (
"os"
"github.com/fxamacker/cbor/v2"
)
type writefile struct {
Path string
Contents []byte
}
type writefileresult struct {
Type string
Id int
WrittenBytes uint64
}
func processWriteFile(cmd command, out chan<- []byte) {
err := os.WriteFile(cmd.WriteFile.Path, cmd.WriteFile.Contents, 0644)
if err != nil {
sendError(out, cmd, err)
return
}
result, _ := cbor.Marshal(writefileresult{
Type: "writefileresult",
Id: cmd.Id,
WrittenBytes: uint64(len(cmd.WriteFile.Contents)),
})
out <- result
}
|