osutil: implement CacheDir on Windows.

Change-Id: I3b41b2a68f0c4222cbfac2945b614964f362e29f
This commit is contained in:
Brad Fitzpatrick 2013-08-04 14:21:36 -07:00
parent d3bca08889
commit aa2ccf9732
1 changed files with 9 additions and 1 deletions

View File

@ -51,7 +51,15 @@ func cacheDir() string {
case "darwin":
return filepath.Join(HomeDir(), "Library", "Caches", "Camlistore")
case "windows":
panic("CacheDir not implemented on OS == " + runtime.GOOS)
// Per http://technet.microsoft.com/en-us/library/cc749104(v=ws.10).aspx
// these should both exist. But that page overwhelms me. Just try them
// both. This seems to work.
for _, ev := range []string{"TEMP", "TMP"} {
if v := os.Getenv(ev); v != "" {
return filepath.Join(v, "Camlistore")
}
}
panic("No Windows TEMP or TMP environment variables found; please file a bug report.")
}
return filepath.Join(HomeDir(), ".cache", "camlistore")
}