From b2d22d91045b6e77fdb8d41a6c3863dd1669b43f Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Wed, 6 Mar 2024 11:51:49 +0100 Subject: [PATCH] use IsDir() in favour of bit mask --- internal/deb/extract_test.go | 3 +-- internal/slicer/report.go | 2 +- internal/slicer/slicer.go | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/deb/extract_test.go b/internal/deb/extract_test.go index b7cd45f0..c3297b4b 100644 --- a/internal/deb/extract_test.go +++ b/internal/deb/extract_test.go @@ -2,7 +2,6 @@ package deb_test import ( "bytes" - "io/fs" "path/filepath" "sort" "strings" @@ -333,7 +332,7 @@ func (s *S) TestExtract(c *C) { createdPaths := make(map[string]bool) options.Create = func(_ *deb.ExtractInfo, o *fsutil.CreateOptions) error { relPath := filepath.Clean("/" + strings.TrimPrefix(o.Path, dir)) - if o.Mode&fs.ModeDir != 0 { + if o.Mode.IsDir() { relPath = relPath + "/" } createdPaths[relPath] = true diff --git a/internal/slicer/report.go b/internal/slicer/report.go index ba85f16c..9d06575b 100644 --- a/internal/slicer/report.go +++ b/internal/slicer/report.go @@ -42,7 +42,7 @@ func (r *Report) Add(slice *setup.Slice, fsEntry *fsutil.Entry) error { return fmt.Errorf("cannot add path %q outside of root %q", fsEntry.Path, r.Root) } relPath := filepath.Clean("/" + strings.TrimPrefix(fsEntry.Path, r.Root)) - if fsEntry.Mode&fs.ModeDir != 0 { + if fsEntry.Mode.IsDir() { relPath = relPath + "/" } diff --git a/internal/slicer/slicer.go b/internal/slicer/slicer.go index 07381505..3130fcce 100644 --- a/internal/slicer/slicer.go +++ b/internal/slicer/slicer.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "io/fs" "os" "path/filepath" "strings" @@ -175,7 +174,7 @@ func Run(options *RunOptions) (*Report, error) { // Check whether the file was created because it matched a glob. if strings.ContainsAny(extractInfo.Path, "*?") { relPath := filepath.Clean("/" + strings.TrimLeft(o.Path, targetDir)) - if o.Mode&fs.ModeDir != 0 { + if o.Mode.IsDir() { relPath = relPath + "/" } globbedPaths[extractInfo.Path] = append(globbedPaths[extractInfo.Path], relPath)