Make the StoreKeys function automatically set up the file if it's not already there
This commit is contained in:
10
I2PAddr.go
10
I2PAddr.go
@ -86,6 +86,16 @@ func StoreKeysIncompat(k I2PKeys, w io.Writer) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StoreKeys(k I2PKeys, r string) error {
|
func StoreKeys(k I2PKeys, r string) error {
|
||||||
|
if _, err := os.Stat(r); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
fi, err := os.Create(r)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer fi.Close()
|
||||||
|
return StoreKeysIncompat(k, fi)
|
||||||
|
}
|
||||||
|
}
|
||||||
fi, err := os.Open(r)
|
fi, err := os.Open(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user