@@ -66,15 +66,15 @@ abstract class ZipArchive(override val jpath: JPath) extends AbstractFile with E
6666 def absolute : AbstractFile = unsupported()
6767
6868 /** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
69- sealed abstract class Entry (path : String ) extends VirtualFile (baseName(path), path) {
69+ sealed abstract class Entry (path : String , val parent : Entry ) extends VirtualFile (baseName(path), path) {
7070 // have to keep this name for compat with sbt's compiler-interface
7171 def getArchive : ZipFile = null
7272 override def underlyingSource : Option [ZipArchive ] = Some (self)
7373 override def toString : String = self.path + " (" + path + " )"
7474 }
7575
7676 /** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */
77- class DirEntry (path : String ) extends Entry (path) {
77+ class DirEntry (path : String , parent : Entry ) extends Entry (path, parent ) {
7878 val entries : mutable.HashMap [String , Entry ] = mutable.HashMap ()
7979
8080 override def isDirectory : Boolean = true
@@ -98,7 +98,7 @@ abstract class ZipArchive(override val jpath: JPath) extends AbstractFile with E
9898 case Some (v) => v
9999 case None =>
100100 val parent = ensureDir(dirs, dirName(path), null )
101- val dir = new DirEntry (path)
101+ val dir = new DirEntry (path, parent )
102102 parent.entries(baseName(path)) = dir
103103 dirs(path) = dir
104104 dir
@@ -120,8 +120,9 @@ final class FileZipArchive(jpath: JPath) extends ZipArchive(jpath) {
120120 private class LazyEntry (
121121 name : String ,
122122 time : Long ,
123- size : Int
124- ) extends Entry (name) {
123+ size : Int ,
124+ parent : DirEntry
125+ ) extends Entry (name, parent) {
125126 override def lastModified : Long = time // could be stale
126127 override def input : InputStream = {
127128 val zipFile = openZipFile()
@@ -140,15 +141,16 @@ final class FileZipArchive(jpath: JPath) extends ZipArchive(jpath) {
140141 // faster than LazyEntry.
141142 private class LeakyEntry (
142143 zipFile : ZipFile ,
143- zipEntry : ZipEntry
144- ) extends Entry (zipEntry.getName) {
144+ zipEntry : ZipEntry ,
145+ parent : DirEntry
146+ ) extends Entry (zipEntry.getName, parent) {
145147 override def lastModified : Long = zipEntry.getTime
146148 override def input : InputStream = zipFile.getInputStream(zipEntry)
147149 override def sizeOption : Option [Int ] = Some (zipEntry.getSize.toInt)
148150 }
149151
150152 @ volatile lazy val (root, allDirs): (DirEntry , collection.Map [String , DirEntry ]) = {
151- val root = new DirEntry (" /" )
153+ val root = new DirEntry (" /" , null )
152154 val dirs = mutable.HashMap [String , DirEntry ](" /" -> root)
153155 val zipFile = openZipFile()
154156 val entries = zipFile.entries()
@@ -163,10 +165,11 @@ final class FileZipArchive(jpath: JPath) extends ZipArchive(jpath) {
163165 new LazyEntry (
164166 zipEntry.getName(),
165167 zipEntry.getTime(),
166- zipEntry.getSize().toInt
168+ zipEntry.getSize().toInt,
169+ dir
167170 )
168171 else
169- new LeakyEntry (zipFile, zipEntry)
172+ new LeakyEntry (zipFile, zipEntry, dir )
170173
171174 dir.entries(f.name) = f
172175 }
@@ -195,15 +198,15 @@ final class FileZipArchive(jpath: JPath) extends ZipArchive(jpath) {
195198
196199final class ManifestResources (val url : URL ) extends ZipArchive (null ) {
197200 def iterator (): Iterator [AbstractFile ] = {
198- val root = new DirEntry (" /" )
201+ val root = new DirEntry (" /" , null )
199202 val dirs = mutable.HashMap [String , DirEntry ](" /" -> root)
200203 val manifest = new Manifest (input)
201204 val iter = manifest.getEntries().keySet().iterator().asScala.filter(_.endsWith(" .class" )).map(new ZipEntry (_))
202205
203206 for (zipEntry <- iter) {
204207 val dir = getDir(dirs, zipEntry)
205208 if (! zipEntry.isDirectory) {
206- val f = new Entry (zipEntry.getName) {
209+ val f = new Entry (zipEntry.getName, dir ) {
207210 override def lastModified = zipEntry.getTime()
208211 override def input = resourceInputStream(path)
209212 override def sizeOption = None
0 commit comments