forked from gobuffalo/genny
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.go
More file actions
32 lines (26 loc) · 629 Bytes
/
file.go
File metadata and controls
32 lines (26 loc) · 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package genny
import (
"bytes"
"io"
"runtime"
"strings"
"github.com/gobuffalo/packd"
)
// File interface for working with files
type File = packd.SimpleFile
// NewFile takes the name of the file you want to
// write to and a reader to reader from
func NewFile(name string, r io.Reader) File {
osname := name
if runtime.GOOS == "windows" {
osname = strings.Replace(osname, "\\", "/", -1)
}
f, _ := packd.NewFile(osname, r)
return f
}
func NewFileS(name string, s string) File {
return NewFile(name, strings.NewReader(s))
}
func NewFileB(name string, s []byte) File {
return NewFile(name, bytes.NewReader(s))
}