diff options
Diffstat (limited to 'src/pkg/archive/zip/struct.go')
-rw-r--r-- | src/pkg/archive/zip/struct.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/archive/zip/struct.go b/src/pkg/archive/zip/struct.go index 73972d41c..65e5238c3 100644 --- a/src/pkg/archive/zip/struct.go +++ b/src/pkg/archive/zip/struct.go @@ -21,6 +21,7 @@ package zip import ( "os" + "path" "time" ) @@ -99,7 +100,7 @@ type headerFileInfo struct { fh *FileHeader } -func (fi headerFileInfo) Name() string { return fi.fh.Name } +func (fi headerFileInfo) Name() string { return path.Base(fi.fh.Name) } func (fi headerFileInfo) Size() int64 { if fi.fh.UncompressedSize64 > 0 { return int64(fi.fh.UncompressedSize64) @@ -113,6 +114,9 @@ func (fi headerFileInfo) Sys() interface{} { return fi.fh } // FileInfoHeader creates a partially-populated FileHeader from an // os.FileInfo. +// Because os.FileInfo's Name method returns only the base name of +// the file it describes, it may be necessary to modify the Name field +// of the returned header to provide the full path name of the file. func FileInfoHeader(fi os.FileInfo) (*FileHeader, error) { size := fi.Size() fh := &FileHeader{ |