IndexBasedZipOps

sbt.internal.inc.IndexBasedZipOps
abstract class IndexBasedZipOps extends CreateZip

Provides efficient implementation of operations on zip files * that are used for implementation of the Straight to Jar feature.

The implementation is based on index (aka central directory) that is located at the end of the zip file and contains among others the name/path and offset where the actual data of stored file is located. Reading zips should always be done based on that index, which means that it is often enough to manipulate this index without rewriting the other part of the file. This class heavily relies on this fact.

This class abstracts over the actual operations on index i.e. reading, manipulating and storing it making it easy to replace.

Attributes

Graph
Supertypes
trait CreateZip
class Object
trait Matchable
class Any
Known subtypes
object IndexBasedZipFsOps.type

Members list

Type members

Classlikes

final class CachedStamps(zip: Path)

Reads timestamps of zip entries. On the first access to a given zip it reads the timestamps once and keeps them cached for future lookups.

Reads timestamps of zip entries. On the first access to a given zip it reads the timestamps once and keeps them cached for future lookups.

It only supports reading stamps from a single zip. The zip passed as an argument is only used to initialize the cache and is later ignored. This is enough as stamps are only read from the output jar.

Attributes

Supertypes
class Object
trait Matchable
class Any

Types

type CentralDir

Represents the central directory (index) of a zip file. It must contain the start offset (where it is located in the zip file) and list of headers

Represents the central directory (index) of a zip file. It must contain the start offset (where it is located in the zip file) and list of headers

Attributes

type Header

Represents a header of a zip entry located inside the central directory. It has to contain the timestamp, name/path and offset to the actual data in zip file.

Represents a header of a zip entry located inside the central directory. It has to contain the timestamp, name/path and offset to the actual data in zip file.

Attributes

Value members

Abstract methods

protected def getCentralDirStart(centralDir: CentralDir): Long
protected def getFileName(header: Header): String
protected def getFileOffset(header: Header): Long
protected def getHeaders(centralDir: CentralDir): Seq[Header]
protected def getLastModifiedTime(header: Header): Long
protected def readCentralDir(path: Path): CentralDir
protected def setCentralDirStart(centralDir: CentralDir, centralDirStart: Long): Unit
protected def setFileOffset(header: Header, offset: Long): Unit
protected def setHeaders(centralDir: CentralDir, headers: Seq[Header]): Unit
protected def writeCentralDir(centralDir: CentralDir, outputStream: OutputStream): Unit

Concrete methods

def includeInArchive(zipFile: File, files: Seq[(File, String)]): Unit

Adds files (plain files) to the specified zip file. Implemented by creating a new zip with the plain files. If zipFile already exists, the archives will be merged. Plain files are not removed after this operation.

Adds files (plain files) to the specified zip file. Implemented by creating a new zip with the plain files. If zipFile already exists, the archives will be merged. Plain files are not removed after this operation.

Value parameters

files

a sequence of tuples with actual file to include and the path in the zip where it should be put.

zipFile

A zip file to add files to

Attributes

def listEntries(zipFile: File): Seq[String]
def mergeArchives(into: File, from: File): Unit

Merges two zip files. It works by appending contents of from to into. Indices are combined, in case of duplicates, the final entries that are used are from from. The final merged zip is available under into path, and from is deleted.

Merges two zip files. It works by appending contents of from to into. Indices are combined, in case of duplicates, the final entries that are used are from from. The final merged zip is available under into path, and from is deleted.

Value parameters

from

the source zip file that is added/merged to into

into

the target zip file to merge to

Attributes

def mergeArchives(target: Path, source: Path): Unit
def readCentralDir(zipFile: File): CentralDir

Reads the current index from given zip file

Reads the current index from given zip file

Value parameters

zipFile

path to the zip file

Attributes

Returns

current index

def removeEntries(zipFile: File, entries: Iterable[String]): Unit

Removes specified entries from given zip file by replacing current index with a version without those entries.

Removes specified entries from given zip file by replacing current index with a version without those entries.

Value parameters

entries

paths to files inside the jar e.g. sbt/internal/inc/IndexBasedZipOps.class

zipFile

the zip file to remove entries from

Attributes

def writeCentralDir(zipFile: File, centralDir: CentralDir): Unit

Replaces index inside the zip file.

Replaces index inside the zip file.

Value parameters

centralDir

the index to be stored in the file

zipFile

the zip file that should have the index updated

Attributes

Inherited methods

def createZip(target: File, files: Seq[(File, String)]): Unit

Attributes

Inherited from:
CreateZip