mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-14 23:07:50 +00:00
19 lines
354 B
Go
19 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: %v", creator, err)
|
||
|
}
|
||
|
return nil
|
||
|
}
|