Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive/tar: provide FileInfo method on Header #4695

Closed
adg opened this issue Jan 23, 2013 · 5 comments
Closed

archive/tar: provide FileInfo method on Header #4695

adg opened this issue Jan 23, 2013 · 5 comments
Milestone

Comments

@adg
Copy link
Contributor

adg commented Jan 23, 2013

The archive/zip package provides a way of divining a FileInfo value from a FileHeader:
  http://tip.golang.org/pkg/archive/zip/#FileHeader.FileInfo

The same should be possible for tar files.
@donovanhide
Copy link
Contributor

Comment 1:

Except for some logic around the Mode, should be as simple as (although untested):
func (h *Header) FileInfo() os.FileInfo {
   return headerFileInfo{h}
}
type tarHeaderFileInfo struct {
    th *Header
}
func (fi tarHeaderFileInfo) Size() int64        { return fi.th.Size }
func (fi tarHeaderFileInfo) IsDir() bool        { return fi.th.Mode == tar.TypeDir }
func (fi tarHeaderFileInfo) ModTime() time.Time { return fi.th.ModTime }
func (fi tarHeaderFileInfo) Mode() os.FileMode  { return os.ModePerm } // Not sure what
this should be
func (fi tarHeaderFileInfo) Sys() interface{}   { return fi.th }

@adg
Copy link
Contributor Author

adg commented Jan 23, 2013

Comment 2:

Please submit a CL! :-)

@mewmew
Copy link
Contributor

mewmew commented Feb 9, 2013

Comment 3:

Work has been done in the following CL: https://golang.org/cl/7305072/

@dsymonds
Copy link
Contributor

Comment 4:

Owner changed to @adg.

Status changed to Started.

@adg
Copy link
Contributor Author

adg commented Feb 14, 2013

Comment 5:

This issue was closed by revision 44d38ae.

Status changed to Fixed.

@adg adg added fixed labels Feb 14, 2013
@adg adg self-assigned this Feb 14, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned adg Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants