mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-28 04:46:44 -04:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user