C# Class ZeroInstall.Store.Implementations.Archives.ArchiveExtractor

Extracts an archive.
Inheritance: NanoByte.Common.Tasks.TaskBase, IDisposable
Datei anzeigen Open project: 0install/0install-win Class Usage Examples

Private Properties

Property Type Description
Create ArchiveExtractor
Create ArchiveExtractor
CreateHardlink void
GetRelativePath string
RemoveExecutableBit void
SetDirectoryWriteTimes void
SetExecutableBit void

Public Methods

Method Description
Dispose ( ) : void

Disposes the underlying Stream.

VerifySupport ( [ mimeType ) : void

Verifies that a archives of a specific MIME type are supported.

Protected Methods

Method Description
ArchiveExtractor ( [ target ) : System

Prepares to extract an archive contained in a stream.

CombinePath ( [ relativePath ) : string

Combines the extraction TargetDir path with the relative path inside the archive (ensuring only valid paths are returned).

CreateDirectory ( [ relativePath, System.DateTime lastWriteTime ) : void

Creates a directory in the filesystem and sets its last write time.

CreateSymlink ( [ source, [ target ) : void

Creates a symbolic link in the filesystem if possible; stores it in a FlagUtils.SymlinkFile otherwise.

Dispose ( bool disposing ) : void
Finish ( ) : void

Performs any tasks that were deferred to the end of the extraction process.

OpenFileWriteStream ( [ relativePath, bool executable = false ) : FileStream

Creates a stream for writing an extracted file to the filesystem.

QueueHardlink ( [ source, [ target, bool executable = false ) : void

Queues a hardlink for creation at the end of the extracton process. This enables handling links to files that have not been extracted yet.

StreamToFile ( [ stream, [ fileStream ) : void

Helper method for WriteFile.

Can be overwritten for archive formats that don't simply write a Stream to a file.

WriteFile ( [ relativePath, long fileSize, System.DateTime lastWriteTime, [ stream, bool executable = false ) : void

Writes a file to the filesystem and sets its last write time.

Private Methods

Method Description
Create ( [ stream, [ target, [ mimeType ) : ArchiveExtractor
Create ( [ path, [ target, [ mimeType = null, long startOffset ) : ArchiveExtractor
CreateHardlink ( [ source, [ target ) : void

Creates a hardlink in the filesystem if possible; creates a copy otherwise.

GetRelativePath ( [ entryName ) : string
RemoveExecutableBit ( string relativePath ) : void

Marks a file as no longer executable using the filesystem if possible, an FlagUtils.XbitFile file otherwise.

SetDirectoryWriteTimes ( ) : void

Sets the last write times of the directories that were recorded during extraction.

This must be done in a separate step, since changing anything within a directory will affect its last write time.

SetExecutableBit ( string relativePath ) : void

Marks a file as executable using the filesystem if possible; stores it in a FlagUtils.XbitFile otherwise.

Method Details

ArchiveExtractor() protected method

Prepares to extract an archive contained in a stream.
protected ArchiveExtractor ( [ target ) : System
target [ The path to the directory to extract into.
return System

CombinePath() protected method

Combines the extraction TargetDir path with the relative path inside the archive (ensuring only valid paths are returned).
is invalid (e.g. is absolute, points outside the archive's root, contains invalid characters).
protected CombinePath ( [ relativePath ) : string
relativePath [ A path relative to .
return string

CreateDirectory() protected method

Creates a directory in the filesystem and sets its last write time.
protected CreateDirectory ( [ relativePath, System.DateTime lastWriteTime ) : void
relativePath [ A path relative to .
lastWriteTime System.DateTime The last write time to set.
return void

CreateSymlink() protected method

Creates a symbolic link in the filesystem if possible; stores it in a FlagUtils.SymlinkFile otherwise.
protected CreateSymlink ( [ source, [ target ) : void
source [ A path relative to .
target [ The target the symbolic link shall point to relative to . May use non-native path separators!
return void

Dispose() public method

Disposes the underlying Stream.
public Dispose ( ) : void
return void

Dispose() protected abstract method

protected abstract Dispose ( bool disposing ) : void
disposing bool
return void

Finish() protected method

Performs any tasks that were deferred to the end of the extraction process.
protected Finish ( ) : void
return void

OpenFileWriteStream() protected method

Creates a stream for writing an extracted file to the filesystem.
protected OpenFileWriteStream ( [ relativePath, bool executable = false ) : FileStream
relativePath [ A path relative to .
executable bool true if the file's executable bit is set; false otherwise.
return System.IO.FileStream

QueueHardlink() protected method

Queues a hardlink for creation at the end of the extracton process. This enables handling links to files that have not been extracted yet.
protected QueueHardlink ( [ source, [ target, bool executable = false ) : void
source [ A path relative to .
target [ A path relative to .
executable bool true if the hardlink's executable bit is set; false otherwise.
return void

StreamToFile() protected method

Helper method for WriteFile.
Can be overwritten for archive formats that don't simply write a Stream to a file.
protected StreamToFile ( [ stream, [ fileStream ) : void
stream [ The stream to write to a file.
fileStream [ Stream access to the file to write.
return void

VerifySupport() public static method

Verifies that a archives of a specific MIME type are supported.
The doesn't belong to a known and supported archive type or is null.
public static VerifySupport ( [ mimeType ) : void
mimeType [ The MIME type of archive format of the stream.
return void

WriteFile() protected method

Writes a file to the filesystem and sets its last write time.
protected WriteFile ( [ relativePath, long fileSize, System.DateTime lastWriteTime, [ stream, bool executable = false ) : void
relativePath [ A path relative to .
fileSize long The length of the zip entries uncompressed data, needed because stream's Length property is always 0.
lastWriteTime System.DateTime The last write time to set.
stream [ The stream containing the file data to be written.
executable bool true if the file's executable bit is set; false otherwise.
return void