Permalink
Browse files

add size property to the zip file

  • Loading branch information...
Quim Muntal Diaz
Quim Muntal Diaz committed Feb 7, 2019
1 parent cf39743 commit 6f9896399a58c7605bb3199dea4bd70b9f4e3bad
Showing with 12 additions and 2 deletions.
  1. +4 −2 reader.go
  2. +4 −0 reader_test.go
  3. +4 −0 zip_reader.go
@@ -10,6 +10,7 @@ import (
type archiveFile interface {
Open() (io.ReadCloser, error)
Name() string
Size() int
}

type archive interface {
@@ -45,7 +46,8 @@ func (r *ReadCloser) Close() error {
// File is used to read a part from the OPC package.
type File struct {
*Part
a archiveFile
Size int
a archiveFile
}

// Open returns a ReadCloser that provides access to the File's contents.
@@ -107,7 +109,7 @@ func (r *Reader) loadPackage() error {
return err
}
part := &Part{Name: fileName, ContentType: cType, Relationships: rels.findRelationship(fileName)}
r.Files = append(r.Files, &File{part, file})
r.Files = append(r.Files, &File{part, file.Size(), file})
r.p.add(part)
}
}
@@ -496,6 +496,10 @@ func (m *mockFile) Name() string {
return args.String(0)
}

func (m *mockFile) Size() int {
return 0
}

type mockArchive struct {
mock.Mock
}
@@ -17,6 +17,10 @@ func (zf *zipFile) Name() string {
return zf.f.Name
}

func (zf *zipFile) Size() int {
return int(zf.f.UncompressedSize64)
}

type zipArchive struct {
r *zip.Reader
}

0 comments on commit 6f98963

Please sign in to comment.