From 3eac44879fd21c0b2136466291d1ce30bd5f8bfe Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 8 Apr 2015 15:14:49 -0700 Subject: [PATCH] Now mc on windows uses C:\Users\\mc as the config directory --- cmd-config.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd-config.go b/cmd-config.go index b2f5c7d2..837b958b 100644 --- a/cmd-config.go +++ b/cmd-config.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path" + "runtime" "strings" "encoding/json" @@ -20,8 +21,9 @@ import ( ) const ( - mcConfigDir = ".minio/mc" - mcConfigFilename = "config.json" + mcConfigDir = ".mc/" + mcConfigWindowsDir = "mc/" + configFile = "config.json" ) type auth struct { @@ -57,12 +59,20 @@ func getMcConfigDir() string { msg := fmt.Sprintf("Unable to obtain user's home directory. \nError: %s", err) fatal(msg) } - - return path.Join(u.HomeDir, mcConfigDir) + var p string + // For windows the path is slightly differently + if runtime.GOOS == "windows" { + p = path.Join(u.HomeDir, mcConfigWindowsDir) + } else { + p = path.Join(u.HomeDir, mcConfigDir) + } + // create the directory if it doesn't exist + os.MkdirAll(p, 0700) + return p } func getMcConfigFilename() string { - return path.Join(getMcConfigDir(), mcConfigFilename) + return path.Join(getMcConfigDir(), configFile) } func getMcConfig() (cfg *mcConfig, err error) {