mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
Create the containing directory if it fails
This commit is contained in:
parent
3aa604de42
commit
6c24be9f46
@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
@ -76,8 +77,15 @@ func (m *Mod) SetMetaName(metaName string) string {
|
||||
func (m Mod) Write() (string, string, error) {
|
||||
f, err := os.Create(m.metaFile)
|
||||
if err != nil {
|
||||
// Attempt to create the containing directory
|
||||
err2 := os.MkdirAll(filepath.Dir(m.metaFile), os.ModePerm)
|
||||
if err2 == nil {
|
||||
f, err = os.Create(m.metaFile)
|
||||
}
|
||||
if err == nil {
|
||||
return "sha256", "", err
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
h := sha256.New()
|
||||
|
Loading…
x
Reference in New Issue
Block a user