mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-28 23:27:36 +00:00
aefb6f9fee
Solution: Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616.
18 lines
367 B
Go
18 lines
367 B
Go
package io
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// MakeDirForFile creates directory provided in filePath.
|
|
func MakeDirForFile(filePath string, creator string) error {
|
|
fileName := filePath
|
|
dir := filepath.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
|
|
}
|