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>
diff --git a/windows/syscall_test.go b/windows/syscall_test.go
index f09c6dd..7e28834 100644
--- a/windows/syscall_test.go
+++ b/windows/syscall_test.go
@@ -62,3 +62,20 @@
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)
+ }
+}