From 948a3c6d0806b1e7a67a5ae3ff6a29a4eae58def Mon Sep 17 00:00:00 2001 From: James Shubin Date: Thu, 29 Nov 2018 16:02:15 -0500 Subject: [PATCH] gapi: Add a bytes helper Use bytes directly if we've got them. --- gapi/helpers.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gapi/helpers.go b/gapi/helpers.go index ddf4965c..93fd7b8c 100644 --- a/gapi/helpers.go +++ b/gapi/helpers.go @@ -42,8 +42,15 @@ func CopyFileToFs(fs engine.Fs, src, dst string) error { return nil } -// CopyStringToFs copies a file from src path on the local fs to a dst path on -// fs. +// CopyBytesToFs copies a list of bytes to a dst path on fs. +func CopyBytesToFs(fs engine.Fs, b []byte, dst string) error { + if err := fs.WriteFile(dst, b, Umask); err != nil { + return errwrap.Wrapf(err, "can't write to file `%s`", dst) + } + return nil +} + +// CopyStringToFs copies a string to a dst path on fs. func CopyStringToFs(fs engine.Fs, str, dst string) error { if err := fs.WriteFile(dst, []byte(str), Umask); err != nil { return errwrap.Wrapf(err, "can't write to file `%s`", dst)