Skip to content

Commit

Permalink
use IsDir() in favour of bit mask
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Mar 6, 2024
1 parent 622e346 commit b2d22d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions internal/deb/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package deb_test

import (
"bytes"
"io/fs"
"path/filepath"
"sort"
"strings"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/slicer/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "/"
}

Expand Down
3 changes: 1 addition & 2 deletions internal/slicer/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b2d22d9

Please sign in to comment.