From 64d2a7c8945ba05af859901f5e248f1befdd8621 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 3 Dec 2013 09:43:15 +0100 Subject: Imported Upstream version 1.2 --- src/pkg/archive/zip/struct.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/pkg/archive/zip/struct.go') 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{ -- cgit v1.2.3