mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 23:30:36 +00:00
0e2784cd2c
It doesn't really change anything in most of the cases, but it's a useful habit anyway. Fix #350.
18 lines
354 B
Go
18 lines
354 B
Go
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 {
|
|
return fmt.Errorf("could not create dir for %s: %w", creator, err)
|
|
}
|
|
return nil
|
|
}
|