From 030169049930174e659a203a4231d26a9ec791d5 Mon Sep 17 00:00:00 2001 From: David Hill Date: Tue, 19 Nov 2013 22:21:50 -0500 Subject: [PATCH] Create the home directory if it doesn't exist. --- util/btcctl/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/util/btcctl/config.go b/util/btcctl/config.go index 49f88fd5..95dc3f8b 100644 --- a/util/btcctl/config.go +++ b/util/btcctl/config.go @@ -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)