From 1eefc28ba62c44d9ece71c8bb4dfd1d35c8f5d74 Mon Sep 17 00:00:00 2001 From: "Dr. Carsten Leue" Date: Wed, 11 Oct 2023 17:36:11 +0200 Subject: [PATCH] fix: remove File.GetName and add Join for convenience Signed-off-by: Dr. Carsten Leue --- context/readerioeither/file/tempfile.go | 3 +-- file/getters.go | 10 ++++++---- ioeither/file/tempfile.go | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/context/readerioeither/file/tempfile.go b/context/readerioeither/file/tempfile.go index 20be139..282806c 100644 --- a/context/readerioeither/file/tempfile.go +++ b/context/readerioeither/file/tempfile.go @@ -19,7 +19,6 @@ import ( "os" RIOE "github.com/IBM/fp-go/context/readerioeither" - FL "github.com/IBM/fp-go/file" F "github.com/IBM/fp-go/function" IO "github.com/IBM/fp-go/io" IOF "github.com/IBM/fp-go/io/file" @@ -32,7 +31,7 @@ var ( // destroy handler onReleaseTempFile = F.Flow4( IOF.Close[*os.File], - IO.Map(FL.GetName), + IO.Map((*os.File).Name), RIOE.FromIO[string], RIOE.Chain(Remove), ) diff --git a/file/getters.go b/file/getters.go index a51561f..113edc1 100644 --- a/file/getters.go +++ b/file/getters.go @@ -15,9 +15,11 @@ package file -import "os" +import "path/filepath" -// GetName is the getter for the `Name` property of [os.File] -func GetName(f *os.File) string { - return f.Name() +// Join appends a filename to a root path +func Join(name string) func(root string) string { + return func(root string) string { + return filepath.Join(root, name) + } } diff --git a/ioeither/file/tempfile.go b/ioeither/file/tempfile.go index e993d5b..5e12f7a 100644 --- a/ioeither/file/tempfile.go +++ b/ioeither/file/tempfile.go @@ -18,7 +18,6 @@ package file import ( "os" - FL "github.com/IBM/fp-go/file" F "github.com/IBM/fp-go/function" IO "github.com/IBM/fp-go/io" IOF "github.com/IBM/fp-go/io/file" @@ -33,7 +32,7 @@ var ( // destroy handler onReleaseTempFile = F.Flow4( IOF.Close[*os.File], - IO.Map(FL.GetName), + IO.Map((*os.File).Name), IOE.FromIO[error, string], IOE.Chain(Remove), )