blob: 0270af07c860e1593db434674495af1d8591be4c (
plain)
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
33
34
|
package libpod
import (
"os"
"path/filepath"
)
// WriteFile writes a provided string to a provided path
func WriteFile(content string, path string) error {
baseDir := filepath.Dir(path)
if baseDir != "" {
if _, err := os.Stat(path); err != nil {
return err
}
}
f, err := os.Create(path)
if err != nil {
return err
}
defer f.Close()
f.WriteString(content)
f.Sync()
return nil
}
// StringInSlice determines if a string is in a string slice, returns bool
func StringInSlice(s string, sl []string) bool {
for _, i := range sl {
if i == s {
return true
}
}
return false
}
|