Skip to content

Commit 0b77ae6

Browse files
committed
refactor: replace hardcoded paths with filepath.Join for Windows build support
Signed-off-by: Rosy-Glorious Miki <rmiki@redhat.com>
1 parent 345d290 commit 0b77ae6

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

pkg/tar-diff/analysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func analyzeForDelta(old *tarInfo, new *tarInfo, oldFile io.Reader) (*deltaAnaly
372372
targetInfoByIndex[hl.index] = &targetInfos[len(targetInfos)-1]
373373
}
374374

375-
tmpfile, err := os.CreateTemp("/var/tmp", "tar-diff-")
375+
tmpfile, err := os.CreateTemp(os.TempDir(), "tar-diff-")
376376
if err != nil {
377377
return nil, err
378378
}

pkg/tar-patch/apply.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"os"
1010
"path"
11+
"path/filepath"
1112

1213
"github.com/containers/tar-diff/pkg/common"
1314
"github.com/klauspost/compress/zstd"
@@ -29,7 +30,7 @@ type FilesystemDataSource struct {
2930
func cleanPath(pathName string) string {
3031
// We make the path always absolute, that way path.Clean() ensure it never goes outside the top ("root") dir
3132
// even if its a relative path
32-
clean := path.Clean("/" + pathName)
33+
clean := path.Clean(path.Join("/", pathName))
3334

3435
// We clean the initial slash, making all result relative (or "" which is error)
3536
return clean[1:]
@@ -69,7 +70,7 @@ func (f *FilesystemDataSource) SetCurrentFile(file string) error {
6970
return nil
7071
}
7172
}
72-
currentFile, err := os.Open(f.basePath + "/" + file)
73+
currentFile, err := os.Open(filepath.Join(f.basePath, file))
7374
if err != nil {
7475
return err
7576
}

0 commit comments

Comments
 (0)