webclient HIDScript: truncate files on overwrite

This commit is contained in:
MaMe82 2018-11-22 20:17:43 +01:00
parent ee594aaf52
commit 452ca52689

View File

@ -5,7 +5,7 @@ import "os"
func WriteFile(path string, mustNotExist bool, append bool, data []byte) (error) {
flag := os.O_CREATE | os.O_WRONLY
if mustNotExist { flag |= os.O_EXCL }
if append { flag |= os.O_APPEND }
if append { flag |= os.O_APPEND } else { flag |= os.O_TRUNC }
f, err := os.OpenFile(path, flag, os.ModePerm)
f.Stat()
if err != nil { return err }