Skip to content

Commit

Permalink
ZipArchive: don't return results as linked list
Browse files Browse the repository at this point in the history
  • Loading branch information
maltek authored and mpollmeier committed Jan 10, 2025
1 parent ee64f24 commit cba2036
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package io.shiftleft.codepropertygraph.cpgloading

import java.io.Closeable
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.{FileSystem, FileSystems, FileVisitResult, Files, Path, Paths, SimpleFileVisitor}
import java.util.{Collection => JCollection}
import java.nio.file.{FileSystem, FileSystems, FileVisitOption, FileVisitResult, Files, Path, Paths, SimpleFileVisitor}
import java.util.Collection as JCollection
import scala.collection.immutable.ArraySeq
import scala.collection.mutable.ArrayBuffer
import scala.jdk.CollectionConverters._
import scala.jdk.CollectionConverters.*

class ZipArchive(inputFile: String) extends Closeable {
private val zipFileSystem: FileSystem = FileSystems.newFileSystem(Paths.get(inputFile), null: ClassLoader)

private def root: Path = zipFileSystem.getRootDirectories.iterator.next

private def walk(rootPath: Path): Seq[Path] = {
val entries = ArrayBuffer[Path]()
val entries = ArraySeq.newBuilder[Path]()
Files.walkFileTree(
rootPath,
new SimpleFileVisitor[Path]() {
Expand All @@ -24,7 +25,7 @@ class ZipArchive(inputFile: String) extends Closeable {
}
}
)
entries.toSeq
entries.result()
}

def entries: Seq[Path] = walk(root)
Expand Down

0 comments on commit cba2036

Please sign in to comment.