aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-07-05 16:34:27 -0400
committerRuss Cox <rsc@golang.org>2020-10-13 00:55:35 +0000
commit84f3b33f10d8f12818975cb188da46145ac2036a (patch)
treefc2157888909a0c04d8f6c4a3974ddb662423a12 /src/internal
parent5ef78c4d84620f6594ad63cbd1b3b43f41670636 (diff)
downloadgo-84f3b33f10d8f12818975cb188da46145ac2036a.tar.gz
go-84f3b33f10d8f12818975cb188da46145ac2036a.zip
syscall: remove dependency on io
Keep syscall and io separated; neither should depend on the other. Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112 Reviewed-on: https://go-review.googlesource.com/c/go/+/243902 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/syscall/windows/registry/key.go17
-rw-r--r--src/internal/syscall/windows/registry/registry_test.go6
-rw-r--r--src/internal/syscall/windows/registry/value.go13
3 files changed, 6 insertions, 30 deletions
diff --git a/src/internal/syscall/windows/registry/key.go b/src/internal/syscall/windows/registry/key.go
index cc3d0c774b..612c48f084 100644
--- a/src/internal/syscall/windows/registry/key.go
+++ b/src/internal/syscall/windows/registry/key.go
@@ -25,10 +25,7 @@
//
package registry
-import (
- "io"
- "syscall"
-)
+import "syscall"
const (
// Registry key security and access rights.
@@ -90,20 +87,13 @@ func OpenKey(k Key, path string, access uint32) (Key, error) {
}
// ReadSubKeyNames returns the names of subkeys of key k.
-// The parameter n controls the number of returned names,
-// analogous to the way os.File.Readdirnames works.
-func (k Key) ReadSubKeyNames(n int) ([]string, error) {
+func (k Key) ReadSubKeyNames() ([]string, error) {
names := make([]string, 0)
// Registry key size limit is 255 bytes and described there:
// https://msdn.microsoft.com/library/windows/desktop/ms724872.aspx
buf := make([]uint16, 256) //plus extra room for terminating zero byte
loopItems:
for i := uint32(0); ; i++ {
- if n > 0 {
- if len(names) == n {
- return names, nil
- }
- }
l := uint32(len(buf))
for {
err := syscall.RegEnumKeyEx(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil)
@@ -123,9 +113,6 @@ loopItems:
}
names = append(names, syscall.UTF16ToString(buf[:l]))
}
- if n > len(names) {
- return names, io.EOF
- }
return names, nil
}
diff --git a/src/internal/syscall/windows/registry/registry_test.go b/src/internal/syscall/windows/registry/registry_test.go
index 8227232c70..5797162900 100644
--- a/src/internal/syscall/windows/registry/registry_test.go
+++ b/src/internal/syscall/windows/registry/registry_test.go
@@ -34,7 +34,7 @@ func TestReadSubKeyNames(t *testing.T) {
}
defer k.Close()
- names, err := k.ReadSubKeyNames(-1)
+ names, err := k.ReadSubKeyNames()
if err != nil {
t.Fatal(err)
}
@@ -190,7 +190,7 @@ func setValues(t *testing.T, k registry.Key) {
}
func enumerateValues(t *testing.T, k registry.Key) {
- names, err := k.ReadValueNames(-1)
+ names, err := k.ReadValueNames()
if err != nil {
t.Error(err)
return
@@ -480,7 +480,7 @@ func deleteValues(t *testing.T, k registry.Key) {
continue
}
}
- names, err := k.ReadValueNames(-1)
+ names, err := k.ReadValueNames()
if err != nil {
t.Error(err)
return
diff --git a/src/internal/syscall/windows/registry/value.go b/src/internal/syscall/windows/registry/value.go
index bf8ab00759..dc3930a6bc 100644
--- a/src/internal/syscall/windows/registry/value.go
+++ b/src/internal/syscall/windows/registry/value.go
@@ -8,7 +8,6 @@ package registry
import (
"errors"
- "io"
"syscall"
"unicode/utf16"
"unsafe"
@@ -341,9 +340,7 @@ func (k Key) DeleteValue(name string) error {
}
// ReadValueNames returns the value names of key k.
-// The parameter n controls the number of returned names,
-// analogous to the way os.File.Readdirnames works.
-func (k Key) ReadValueNames(n int) ([]string, error) {
+func (k Key) ReadValueNames() ([]string, error) {
ki, err := k.Stat()
if err != nil {
return nil, err
@@ -352,11 +349,6 @@ func (k Key) ReadValueNames(n int) ([]string, error) {
buf := make([]uint16, ki.MaxValueNameLen+1) // extra room for terminating null character
loopItems:
for i := uint32(0); ; i++ {
- if n > 0 {
- if len(names) == n {
- return names, nil
- }
- }
l := uint32(len(buf))
for {
err := regEnumValue(syscall.Handle(k), i, &buf[0], &l, nil, nil, nil, nil)
@@ -376,8 +368,5 @@ loopItems:
}
names = append(names, syscall.UTF16ToString(buf[:l]))
}
- if n > len(names) {
- return names, io.EOF
- }
return names, nil
}