2019-11-06 14:12:33 +00:00
|
|
|
package io
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MakeDirForFile creates directory provided in filePath.
|
|
|
|
func MakeDirForFile(filePath string, creator string) error {
|
|
|
|
fileName := filePath
|
|
|
|
dir := path.Dir(fileName)
|
|
|
|
err := os.MkdirAll(dir, os.ModePerm)
|
|
|
|
if err != nil {
|
2020-08-06 16:09:57 +00:00
|
|
|
return fmt.Errorf("could not create dir for %s: %w", creator, err)
|
2019-11-06 14:12:33 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|