From ea2d45692d47405e85396a64244ce1cb6ad16f5d Mon Sep 17 00:00:00 2001 From: shaoying Date: Sat, 30 Jun 2018 10:30:48 +0800 Subject: [PATCH] tce add nfs.append --- src/contexts/nfs/nfs.go | 6 ++++++ usr/template/upload.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 71f9ccbd..74bfd7f5 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -927,6 +927,12 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心", fmt.Fprint(f, strings.Join(arg[1:], "")) } // }}} }}, + "append": &ctx.Command{Name: "append file string...", Help: "写入文件, string: 写入内容, pos: 写入位置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { + if f, e := os.OpenFile(arg[0], os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666); m.Assert(e) { // {{{ + defer f.Close() + fmt.Fprint(f, strings.Join(arg[1:], "")) + } // }}} + }}, "genqr": &ctx.Command{Name: "genqr [size] file string...", Help: "写入文件, string: 写入内容, pos: 写入位置", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) { size := 256 // {{{ if len(arg) > 2 { diff --git a/usr/template/upload.html b/usr/template/upload.html index 50df2662..70a7c419 100644 --- a/usr/template/upload.html +++ b/usr/template/upload.html @@ -26,7 +26,7 @@ {{range $key := index $meta "append"}} {{if eq $key "name"}} - {{index $meta $key $i}} + {{index $meta $key $i}} {{else if eq $key "path"}} {{else}}