windows: add Windows directory accessors

These are useful for the same reason that the already existing
GetSystemDirectory is.

Change-Id: I3041ce6cbeb66a4f8a5960fbaf39381c8c9c80d6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/191837
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Jason A. Donenfeld
2019-08-26 19:00:57 +00:00
parent acd9dae8e8
commit c7b8b68b14
3 changed files with 85 additions and 2 deletions
+17
View File
@@ -62,3 +62,20 @@ func TestGetSystemDirectory(t *testing.T) {
t.Fatalf("System directory does not end in system32: %s", d)
}
}
func TestGetWindowsDirectory(t *testing.T) {
d1, err := windows.GetWindowsDirectory()
if err != nil {
t.Fatalf("Failed to get Windows directory: %s", err)
}
d2, err := windows.GetSystemWindowsDirectory()
if err != nil {
t.Fatalf("Failed to get system Windows directory: %s", err)
}
if !strings.HasSuffix(strings.ToLower(d1), `\windows`) {
t.Fatalf("Windows directory does not end in windows: %s", d1)
}
if !strings.HasSuffix(strings.ToLower(d2), `\windows`) {
t.Fatalf("System Windows directory does not end in windows: %s", d2)
}
}