diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2017-11-01 15:30:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-01 15:30:35 -0400 |
commit | d7782cc31e809d8e1551f47a0ddb0ff8073005fc (patch) | |
tree | 625fdeaf51ffced387b4ba2e48d93288f3f1b9b2 /libpod/util.go | |
parent | f5019df3f5da9030ce21e5c8ad3d3921a6585e7f (diff) | |
parent | 8cf07b2ad1ed8c6646c48a74e9ecbb2bfeecb322 (diff) | |
download | podman-d7782cc31e809d8e1551f47a0ddb0ff8073005fc.tar.gz podman-d7782cc31e809d8e1551f47a0ddb0ff8073005fc.tar.bz2 podman-d7782cc31e809d8e1551f47a0ddb0ff8073005fc.zip |
Merge pull request #2 from baude/create
libpod create and run
Diffstat (limited to 'libpod/util.go')
-rw-r--r-- | libpod/util.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go new file mode 100644 index 000000000..0270af07c --- /dev/null +++ b/libpod/util.go @@ -0,0 +1,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 +} |