Create the home directory if it doesn't exist.

This commit is contained in:
David Hill 2013-11-19 22:21:50 -05:00
parent 9643cb6d23
commit 0301690499

View file

@ -49,6 +49,13 @@ func loadConfig() (*flags.Parser, *config, []string, error) {
RPCCert: defaultRPCCertFile,
}
// Create the home directory if it doesn't already exist.
err := os.MkdirAll(btcdHomeDir, 0700)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(-1)
}
// Pre-parse the command line options to see if an alternative config
// file or the version flag was specified. Any errors can be ignored
// here since they will be caught be the final parse below.
@ -66,7 +73,7 @@ func loadConfig() (*flags.Parser, *config, []string, error) {
// Load additional config from file.
parser := flags.NewParser(&cfg, flags.PassDoubleDash|flags.HelpFlag)
err := parser.ParseIniFile(preCfg.ConfigFile)
err = parser.ParseIniFile(preCfg.ConfigFile)
if err != nil {
if _, ok := err.(*os.PathError); !ok {
fmt.Fprintln(os.Stderr, err)