gapi: Add a bytes helper

Use bytes directly if we've got them.
This commit is contained in:
James Shubin
2018-11-29 16:02:15 -05:00
parent dc13d5d26b
commit 948a3c6d08

View File

@@ -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)