engine, lang, gapi: Split out some functions to a writeable API
Start breaking down the filesystem interface to make things more flexible.
This commit is contained in:
@@ -30,7 +30,7 @@ import (
|
||||
const Umask = 0666
|
||||
|
||||
// CopyFileToFs copies a file from src path on the local fs to a dst path on fs.
|
||||
func CopyFileToFs(fs engine.Fs, src, dst string) error {
|
||||
func CopyFileToFs(fs engine.WriteableFS, src, dst string) error {
|
||||
data, err := ioutil.ReadFile(src)
|
||||
if err != nil {
|
||||
return errwrap.Wrapf(err, "can't read from file `%s`", src)
|
||||
@@ -42,7 +42,7 @@ func CopyFileToFs(fs engine.Fs, src, dst string) error {
|
||||
}
|
||||
|
||||
// CopyBytesToFs copies a list of bytes to a dst path on fs.
|
||||
func CopyBytesToFs(fs engine.Fs, b []byte, dst string) error {
|
||||
func CopyBytesToFs(fs engine.WriteableFS, 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)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func CopyBytesToFs(fs engine.Fs, b []byte, dst string) error {
|
||||
}
|
||||
|
||||
// CopyStringToFs copies a string to a dst path on fs.
|
||||
func CopyStringToFs(fs engine.Fs, str, dst string) error {
|
||||
func CopyStringToFs(fs engine.WriteableFS, 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user