@@ -13,8 +13,8 @@ package tar
1313import (
1414 "errors"
1515 "fmt"
16+ "io/fs"
1617 "math"
17- "os"
1818 "path"
1919 "reflect"
2020 "strconv"
@@ -525,12 +525,12 @@ func (h Header) allowedFormats() (format Format, paxHdrs map[string]string, err
525525 return format , paxHdrs , err
526526}
527527
528- // FileInfo returns an os .FileInfo for the Header.
529- func (h * Header ) FileInfo () os .FileInfo {
528+ // FileInfo returns an fs .FileInfo for the Header.
529+ func (h * Header ) FileInfo () fs .FileInfo {
530530 return headerFileInfo {h }
531531}
532532
533- // headerFileInfo implements os .FileInfo.
533+ // headerFileInfo implements fs .FileInfo.
534534type headerFileInfo struct {
535535 h * Header
536536}
@@ -549,57 +549,57 @@ func (fi headerFileInfo) Name() string {
549549}
550550
551551// Mode returns the permission and mode bits for the headerFileInfo.
552- func (fi headerFileInfo ) Mode () (mode os .FileMode ) {
552+ func (fi headerFileInfo ) Mode () (mode fs .FileMode ) {
553553 // Set file permission bits.
554- mode = os .FileMode (fi .h .Mode ).Perm ()
554+ mode = fs .FileMode (fi .h .Mode ).Perm ()
555555
556556 // Set setuid, setgid and sticky bits.
557557 if fi .h .Mode & c_ISUID != 0 {
558- mode |= os .ModeSetuid
558+ mode |= fs .ModeSetuid
559559 }
560560 if fi .h .Mode & c_ISGID != 0 {
561- mode |= os .ModeSetgid
561+ mode |= fs .ModeSetgid
562562 }
563563 if fi .h .Mode & c_ISVTX != 0 {
564- mode |= os .ModeSticky
564+ mode |= fs .ModeSticky
565565 }
566566
567567 // Set file mode bits; clear perm, setuid, setgid, and sticky bits.
568- switch m := os .FileMode (fi .h .Mode ) &^ 07777 ; m {
568+ switch m := fs .FileMode (fi .h .Mode ) &^ 07777 ; m {
569569 case c_ISDIR :
570- mode |= os .ModeDir
570+ mode |= fs .ModeDir
571571 case c_ISFIFO :
572- mode |= os .ModeNamedPipe
572+ mode |= fs .ModeNamedPipe
573573 case c_ISLNK :
574- mode |= os .ModeSymlink
574+ mode |= fs .ModeSymlink
575575 case c_ISBLK :
576- mode |= os .ModeDevice
576+ mode |= fs .ModeDevice
577577 case c_ISCHR :
578- mode |= os .ModeDevice
579- mode |= os .ModeCharDevice
578+ mode |= fs .ModeDevice
579+ mode |= fs .ModeCharDevice
580580 case c_ISSOCK :
581- mode |= os .ModeSocket
581+ mode |= fs .ModeSocket
582582 }
583583
584584 switch fi .h .Typeflag {
585585 case TypeSymlink :
586- mode |= os .ModeSymlink
586+ mode |= fs .ModeSymlink
587587 case TypeChar :
588- mode |= os .ModeDevice
589- mode |= os .ModeCharDevice
588+ mode |= fs .ModeDevice
589+ mode |= fs .ModeCharDevice
590590 case TypeBlock :
591- mode |= os .ModeDevice
591+ mode |= fs .ModeDevice
592592 case TypeDir :
593- mode |= os .ModeDir
593+ mode |= fs .ModeDir
594594 case TypeFifo :
595- mode |= os .ModeNamedPipe
595+ mode |= fs .ModeNamedPipe
596596 }
597597
598598 return mode
599599}
600600
601601// sysStat, if non-nil, populates h from system-dependent fields of fi.
602- var sysStat func (fi os .FileInfo , h * Header ) error
602+ var sysStat func (fi fs .FileInfo , h * Header ) error
603603
604604const (
605605 // Mode constants from the USTAR spec:
@@ -623,10 +623,10 @@ const (
623623// If fi describes a symlink, FileInfoHeader records link as the link target.
624624// If fi describes a directory, a slash is appended to the name.
625625//
626- // Since os .FileInfo's Name method only returns the base name of
626+ // Since fs .FileInfo's Name method only returns the base name of
627627// the file it describes, it may be necessary to modify Header.Name
628628// to provide the full path name of the file.
629- func FileInfoHeader (fi os .FileInfo , link string ) (* Header , error ) {
629+ func FileInfoHeader (fi fs .FileInfo , link string ) (* Header , error ) {
630630 if fi == nil {
631631 return nil , errors .New ("archive/tar: FileInfo is nil" )
632632 }
@@ -643,29 +643,29 @@ func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
643643 case fi .IsDir ():
644644 h .Typeflag = TypeDir
645645 h .Name += "/"
646- case fm & os .ModeSymlink != 0 :
646+ case fm & fs .ModeSymlink != 0 :
647647 h .Typeflag = TypeSymlink
648648 h .Linkname = link
649- case fm & os .ModeDevice != 0 :
650- if fm & os .ModeCharDevice != 0 {
649+ case fm & fs .ModeDevice != 0 :
650+ if fm & fs .ModeCharDevice != 0 {
651651 h .Typeflag = TypeChar
652652 } else {
653653 h .Typeflag = TypeBlock
654654 }
655- case fm & os .ModeNamedPipe != 0 :
655+ case fm & fs .ModeNamedPipe != 0 :
656656 h .Typeflag = TypeFifo
657- case fm & os .ModeSocket != 0 :
657+ case fm & fs .ModeSocket != 0 :
658658 return nil , fmt .Errorf ("archive/tar: sockets not supported" )
659659 default :
660660 return nil , fmt .Errorf ("archive/tar: unknown file mode %v" , fm )
661661 }
662- if fm & os .ModeSetuid != 0 {
662+ if fm & fs .ModeSetuid != 0 {
663663 h .Mode |= c_ISUID
664664 }
665- if fm & os .ModeSetgid != 0 {
665+ if fm & fs .ModeSetgid != 0 {
666666 h .Mode |= c_ISGID
667667 }
668- if fm & os .ModeSticky != 0 {
668+ if fm & fs .ModeSticky != 0 {
669669 h .Mode |= c_ISVTX
670670 }
671671 // If possible, populate additional fields from OS-specific
0 commit comments