From 3b1abc890c2ab4df1321a88487119e132e262faf Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:43:45 -0400 Subject: [PATCH 1/4] add FilesWithNames() --- activation/files_unix.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/activation/files_unix.go b/activation/files_unix.go index bf7671dd..29c27000 100644 --- a/activation/files_unix.go +++ b/activation/files_unix.go @@ -68,3 +68,22 @@ func Files(unsetEnv bool) []*os.File { return files } + +// FilesWithNames maps fd names to a set of os.File pointers. +func FilesWithNames() map[string][]*os.File { + files := activation.Files(true) + filesWithNames := map[string][]*os.File{} + + for _, f := range files { + current, ok := filesWithNames[f.Name()] + + if !ok { + current = []*os.File{} + filesWithNames[f.Name()] = current + } + + filesWithNames[f.Name()] = append(current, f) + } + + return filesWithNames +} From 7fd1a0c41d11d5ecdd72099bbc074da37f95df99 Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:49:06 -0400 Subject: [PATCH 2/4] Update files_windows.go --- activation/files_windows.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/activation/files_windows.go b/activation/files_windows.go index d391bf00..f3e0afe9 100644 --- a/activation/files_windows.go +++ b/activation/files_windows.go @@ -19,3 +19,22 @@ import "os" func Files(unsetEnv bool) []*os.File { return nil } + +// FilesWithNames maps fd names to a set of os.File pointers. +func FilesWithNames() map[string][]*os.File { + files := activation.Files(true) + filesWithNames := map[string][]*os.File{} + + for _, f := range files { + current, ok := filesWithNames[f.Name()] + + if !ok { + current = []*os.File{} + filesWithNames[f.Name()] = current + } + + filesWithNames[f.Name()] = append(current, f) + } + + return filesWithNames +} From 0015ee14fc4a424d0b462c1a67d9afcf353347d5 Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:50:19 -0400 Subject: [PATCH 3/4] Update files_unix.go --- activation/files_unix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activation/files_unix.go b/activation/files_unix.go index 29c27000..d51dcbbf 100644 --- a/activation/files_unix.go +++ b/activation/files_unix.go @@ -71,7 +71,7 @@ func Files(unsetEnv bool) []*os.File { // FilesWithNames maps fd names to a set of os.File pointers. func FilesWithNames() map[string][]*os.File { - files := activation.Files(true) + files := Files(true) filesWithNames := map[string][]*os.File{} for _, f := range files { From 125bf9288a6f8a05f97d9a4c1d55fa0257aa09a4 Mon Sep 17 00:00:00 2001 From: Aaron Paterson <9441877+MayCXC@users.noreply.github.com> Date: Wed, 9 Oct 2024 01:50:33 -0400 Subject: [PATCH 4/4] Update files_windows.go --- activation/files_windows.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activation/files_windows.go b/activation/files_windows.go index f3e0afe9..3f2aa8af 100644 --- a/activation/files_windows.go +++ b/activation/files_windows.go @@ -22,7 +22,7 @@ func Files(unsetEnv bool) []*os.File { // FilesWithNames maps fd names to a set of os.File pointers. func FilesWithNames() map[string][]*os.File { - files := activation.Files(true) + files := Files(true) filesWithNames := map[string][]*os.File{} for _, f := range files {