Skip to content

Commit

Permalink
fix: remove File.GetName and add Join for convenience
Browse files Browse the repository at this point in the history
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
  • Loading branch information
CarstenLeue committed Oct 11, 2023
1 parent af2915d commit 1eefc28
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions context/readerioeither/file/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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),
)
Expand Down
10 changes: 6 additions & 4 deletions file/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
3 changes: 1 addition & 2 deletions ioeither/file/tempfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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),
)
Expand Down

0 comments on commit 1eefc28

Please sign in to comment.