mirror of
https://github.com/go-i2p/i2pkeys.git
synced 2025-06-11 02:08:35 -04:00
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 {
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user