2017-07-01 23:00:06 +02:00
|
|
|
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
|
|
|
|
package tools
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
2017-07-05 02:52:25 +02:00
|
|
|
// EnsureDir ensures that a target directory exists (like `mkdir -p`), returning a non-nil error if any problem occurs.
|
|
|
|
func EnsureDir(dir string) error {
|
2017-07-01 23:00:06 +02:00
|
|
|
return os.MkdirAll(dir, 0700)
|
|
|
|
}
|
2017-07-05 02:52:25 +02:00
|
|
|
|
|
|
|
// EnsureFileDir ensures that a target file's parent directory exists, returning a non-nil error if any problem occurs.
|
|
|
|
func EnsureFileDir(path string) error {
|
|
|
|
return EnsureDir(filepath.Dir(path))
|
|
|
|
}
|