Fingerprint_Card

Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Tar.TarArchive Class Reference

The TarArchive class implements the concept of a 'Tape Archive'. A tar archive is a series of entries, each of which represents a file system object. Each entry in the archive consists of a header block followed by 0 or more data blocks. Directory entries consist only of the header block, and are followed by entries for the directory's contents. File entries consist of a header followed by the number of blocks needed to contain the file's contents. All entries are written on block boundaries. Blocks are 512 bytes long. More...

Inheritance diagram for ICSharpCode.SharpZipLib.Tar.TarArchive:
[legend]
Collaboration diagram for ICSharpCode.SharpZipLib.Tar.TarArchive:
[legend]

## Public Member Functions
void | SetKeepOldFiles (bool keepExistingFiles)
| Set the flag that determines whether existing files are kept, or overwritten during extraction.
void | SetAsciiTranslation (bool translateAsciiFiles)
| Set the ascii file translation flag.
void | SetUserInfo (int userId, string userName, int groupId, string groupName)
| Set user and group information that will be used to fill in the tar archive's entry headers. This information is based on that available for the linux operating system, which is not always available on other operating systems. TarArchive allows the programmer to specify values to be used in their place. ApplyUserInfoOverrides is set to true by this call.
void | CloseArchive ()
| Close the archive.
void | ListContents ()
| Perform the "list" command for the archive contents.
void | ExtractContents (string destinationDirectory)
| Perform the "extract" command and extract the contents of the archive.
void | WriteEntry (TarEntry sourceEntry, bool recurse)
| Write an entry to the archive. This method will call the putNextEntry and then write the contents of the entry, and finally call closeEntry() for entries that are files. For directories, it will call putNextEntry(), and then, if the recurse flag is true, process each entry that is a child of the directory.
void | Dispose ()
| Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
virtual void | Close ()
| Closes the archive and releases any associated resources.

## Static Public Member Functions
static TarArchive | CreateInputTarArchive (Stream inputStream)
| The InputStream based constructors create a TarArchive for the purposes of extracting or listing a tar archive. Thus, use these constructors when you wish to extract files from or list the contents of an existing tar archive.
static TarArchive | CreateInputTarArchive (Stream inputStream, int blockFactor)
| Create TarArchive for reading setting block factor.
static TarArchive | CreateOutputTarArchive (Stream outputStream)
| Create a TarArchive for writing to, using the default blocking factor.
static TarArchive | CreateOutputTarArchive (Stream outputStream, int blockFactor)
| Create a tar archive for writing.

## Protected Member Functions
virtual void | OnProgressMessageEvent (TarEntry entry, string message)
| Raises the ProgressMessage event.
| TarArchive ()
| Constructor for a default TarArchive.
| TarArchive (TarInputStream stream)
| Initalise a TarArchive for input.
| TarArchive (TarOutputStream stream)
| Initialise a TarArchive for output.
virtual void | Dispose (bool disposing)
| Releases the unmanaged resources used by the FileStream and optionally releases the managed resources.

## Properties
bool | AsciiTranslate`[get, set]`
| Get/set the ascii file translation flag. If ascii file translation is true, then the file is checked to see if it a binary file or not. If the flag is true and the test indicates it is ascii text file, it will be translated. The translation converts the local operating system's concept of line ends into the UNIX line end, ' ', which is the defacto standard for a TAR archive. This makes text files compatible with UNIX.
string | PathPrefix`[get, set]`
| PathPrefix is added to entry names as they are written if the value is not null. A slash character is appended after PathPrefix.
string | RootPath`[get, set]`
| RootPath is removed from entry names if it is found at the beginning of the name.
bool | ApplyUserInfoOverrides`[get, set]`
| Get or set a value indicating if overrides defined by SetUserInfo should be applied.
int | UserId`[get]`
| Get the archive user id. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.
string | UserName`[get]`
| Get the archive user name. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.
int | GroupId`[get]`
| Get the archive group id. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.
string | GroupName`[get]`
| Get the archive group name. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.
int | RecordSize`[get]`
| Get the archive's record size. Tar archives are composed of a series of RECORDS each containing a number of BLOCKS. This allowed tar archives to match the IO characteristics of the physical device being used. Archives are expected to be properly "blocked".
bool | IsStreamOwner`[set]`
| Sets the IsStreamOwner property on the underlying stream. Set this to false to prevent the Close of the TarArchive from closing the stream.

## Events
ProgressMessageHandler | ProgressMessageEvent
| Client hook allowing detailed information to be reported during processing.

## Private Member Functions
void | ExtractEntry (string destDir, TarEntry entry)
| Extract an entry from the archive. This method assumes that the tarIn stream has been properly set with a call to GetNextEntry().
void | WriteEntryCore (TarEntry sourceEntry, bool recurse)
| Write an entry to the archive. This method will call the putNextEntry and then write the contents of the entry, and finally call closeEntry() for entries that are files. For directories, it will call putNextEntry(), and then, if the recurse flag is true, process each entry that is a child of the directory.
| ~TarArchive ()
| Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the TarArchive.

## Static Private Member Functions
static void | EnsureDirectoryExists (string directoryName)
static bool | IsBinary (string filename)

## Private Attributes
bool | keepOldFiles
bool | asciiTranslate
int | userId
string | userName = string.Empty
int | groupId
string | groupName = string.Empty
string | rootPath
string | pathPrefix
bool | applyUserInfoOverrides
TarInputStream | tarIn
TarOutputStream | tarOut
bool | isDisposed

## Detailed Description

The TarArchive class implements the concept of a 'Tape Archive'. A tar archive is a series of entries, each of which represents a file system object. Each entry in the archive consists of a header block followed by 0 or more data blocks. Directory entries consist only of the header block, and are followed by entries for the directory's contents. File entries consist of a header followed by the number of blocks needed to contain the file's contents. All entries are written on block boundaries. Blocks are 512 bytes long.

TarArchives are instantiated in either read or write mode, based upon whether they are instantiated with an InputStream or an OutputStream. Once instantiated TarArchives read/write mode can not be changed.

There is currently no support for random access to tar archives. However, it seems that subclassing TarArchive, and using the TarBuffer.CurrentRecord and TarBuffer.CurrentBlock properties, this would be rather trivial.

## Constructor & Destructor Documentation

## ◆ TarArchive() [1/3]

ICSharpCode.SharpZipLib.Tar.TarArchive.TarArchive | ( |  | ) |
| protected

Constructor for a default TarArchive.

Here is the caller graph for this function:

## ◆ TarArchive() [2/3]

ICSharpCode.SharpZipLib.Tar.TarArchive.TarArchive | ( | TarInputStream | stream | ) |
| protected

Initalise a TarArchive for input.

Parameters

  stream | The TarInputStream to use for input.

## ◆ TarArchive() [3/3]

ICSharpCode.SharpZipLib.Tar.TarArchive.TarArchive | ( | TarOutputStream | stream | ) |
| protected

Initialise a TarArchive for output.

Parameters

  stream | The TarOutputStream to use for output.

## ◆ ~TarArchive()

ICSharpCode.SharpZipLib.Tar.TarArchive.~TarArchive | ( |  | ) |
| private

Ensures that resources are freed and other cleanup operations are performed when the garbage collector reclaims the TarArchive.

Here is the call graph for this function:

## Member Function Documentation

## ◆ Close()

virtual void ICSharpCode.SharpZipLib.Tar.TarArchive.Close | ( |  | ) |
| virtual

Closes the archive and releases any associated resources.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ CloseArchive()

void ICSharpCode.SharpZipLib.Tar.TarArchive.CloseArchive | ( |  | ) |

Close the archive.

Here is the call graph for this function:

## ◆ CreateInputTarArchive() [1/2]

TarArchive ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive | ( | Stream | inputStream | ) |
| static

The InputStream based constructors create a TarArchive for the purposes of extracting or listing a tar archive. Thus, use these constructors when you wish to extract files from or list the contents of an existing tar archive.

Parameters

  inputStream | The stream to retrieve archive data from.

Returns
  Returns a new TarArchive suitable for reading from.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ CreateInputTarArchive() [2/2]

TarArchive ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive | ( | Stream | inputStream,
|  | int | blockFactor )
| static

Create TarArchive for reading setting block factor.

Parameters

  inputStream | A stream containing the tar archive contents
  blockFactor | The blocking factor to apply

Returns
  Returns a TarArchive suitable for reading.

Here is the call graph for this function:

## ◆ CreateOutputTarArchive() [1/2]

TarArchive ICSharpCode.SharpZipLib.Tar.TarArchive.CreateOutputTarArchive | ( | Stream | outputStream | ) |
| static

Create a TarArchive for writing to, using the default blocking factor.

Parameters

  outputStream | The Stream to write to

Returns
  Returns a TarArchive suitable for writing.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ CreateOutputTarArchive() [2/2]

TarArchive ICSharpCode.SharpZipLib.Tar.TarArchive.CreateOutputTarArchive | ( | Stream | outputStream,
|  | int | blockFactor )
| static

Create a tar archive for writing.

Parameters

  outputStream | The stream to write to
  blockFactor | The blocking factor to use for buffering.

Returns
  Returns a TarArchive suitable for writing.

Here is the call graph for this function:

## ◆ Dispose() [1/2]

void ICSharpCode.SharpZipLib.Tar.TarArchive.Dispose | ( |  | ) |

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ Dispose() [2/2]

virtual void ICSharpCode.SharpZipLib.Tar.TarArchive.Dispose | ( | bool | disposing | ) |
| protected virtual

Releases the unmanaged resources used by the FileStream and optionally releases the managed resources.

Parameters

  disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources.

## ◆ EnsureDirectoryExists()

void ICSharpCode.SharpZipLib.Tar.TarArchive.EnsureDirectoryExists | ( | string | directoryName | ) |
| static private

Here is the caller graph for this function:

## ◆ ExtractContents()

void ICSharpCode.SharpZipLib.Tar.TarArchive.ExtractContents | ( | string | destinationDirectory | ) |

Perform the "extract" command and extract the contents of the archive.

Parameters

  destinationDirectory | The destination directory into which to extract.

Here is the call graph for this function:

## ◆ ExtractEntry()

void ICSharpCode.SharpZipLib.Tar.TarArchive.ExtractEntry | ( | string | destDir,
|  | TarEntry | entry )
| private

Extract an entry from the archive. This method assumes that the tarIn stream has been properly set with a call to GetNextEntry().

Parameters

  destDir | The destination directory into which to extract.
  entry | The TarEntry returned by tarIn.GetNextEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ IsBinary()

bool ICSharpCode.SharpZipLib.Tar.TarArchive.IsBinary | ( | string | filename | ) |
| static private

Here is the caller graph for this function:

## ◆ ListContents()

void ICSharpCode.SharpZipLib.Tar.TarArchive.ListContents | ( |  | ) |

Perform the "list" command for the archive contents.

NOTE That this method uses the progress event to actually list the contents. If the progress display event is not set, nothing will be listed!

Here is the call graph for this function:

## ◆ OnProgressMessageEvent()

virtual void ICSharpCode.SharpZipLib.Tar.TarArchive.OnProgressMessageEvent | ( | TarEntry | entry,
|  | string | message )
| protected virtual

Raises the ProgressMessage event.

Parameters

  entry | The TarEntry for this event
  message | message for this event. Null is no message

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ SetAsciiTranslation()

void ICSharpCode.SharpZipLib.Tar.TarArchive.SetAsciiTranslation | ( | bool | translateAsciiFiles | ) |

Set the ascii file translation flag.

Parameters

  translateAsciiFiles | If true, translate ascii text files.

## ◆ SetKeepOldFiles()

void ICSharpCode.SharpZipLib.Tar.TarArchive.SetKeepOldFiles | ( | bool | keepExistingFiles | ) |

Set the flag that determines whether existing files are kept, or overwritten during extraction.

Parameters

  keepExistingFiles | If true, do not overwrite existing files.

## ◆ SetUserInfo()

void ICSharpCode.SharpZipLib.Tar.TarArchive.SetUserInfo | ( | int | userId,
|  | string | userName,
|  | int | groupId,
|  | string | groupName )

Set user and group information that will be used to fill in the tar archive's entry headers. This information is based on that available for the linux operating system, which is not always available on other operating systems. TarArchive allows the programmer to specify values to be used in their place. ApplyUserInfoOverrides is set to true by this call.

Parameters

  userId | The user id to use in the headers.
  userName | The user name to use in the headers.
  groupId | The group id to use in the headers.
  groupName | The group name to use in the headers.

## ◆ WriteEntry()

void ICSharpCode.SharpZipLib.Tar.TarArchive.WriteEntry | ( | TarEntry | sourceEntry,
|  | bool | recurse )

Write an entry to the archive. This method will call the putNextEntry and then write the contents of the entry, and finally call closeEntry() for entries that are files. For directories, it will call putNextEntry(), and then, if the recurse flag is true, process each entry that is a child of the directory.

Parameters

  sourceEntry | The TarEntry representing the entry to write to the archive.
  recurse | If true, process the children of directory entries.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ WriteEntryCore()

void ICSharpCode.SharpZipLib.Tar.TarArchive.WriteEntryCore | ( | TarEntry | sourceEntry,
|  | bool | recurse )
| private

Write an entry to the archive. This method will call the putNextEntry and then write the contents of the entry, and finally call closeEntry() for entries that are files. For directories, it will call putNextEntry(), and then, if the recurse flag is true, process each entry that is a child of the directory.

Parameters

  sourceEntry | The TarEntry representing the entry to write to the archive.
  recurse | If true, process the children of directory entries.

Here is the call graph for this function:
Here is the caller graph for this function:

## Member Data Documentation

## ◆ applyUserInfoOverrides

bool ICSharpCode.SharpZipLib.Tar.TarArchive.applyUserInfoOverrides
| private

## ◆ asciiTranslate

bool ICSharpCode.SharpZipLib.Tar.TarArchive.asciiTranslate
| private

## ◆ groupId

int ICSharpCode.SharpZipLib.Tar.TarArchive.groupId
| private

## ◆ groupName

string ICSharpCode.SharpZipLib.Tar.TarArchive.groupName = string.Empty
| private

## ◆ isDisposed

bool ICSharpCode.SharpZipLib.Tar.TarArchive.isDisposed
| private

## ◆ keepOldFiles

bool ICSharpCode.SharpZipLib.Tar.TarArchive.keepOldFiles
| private

## ◆ pathPrefix

string ICSharpCode.SharpZipLib.Tar.TarArchive.pathPrefix
| private

## ◆ rootPath

string ICSharpCode.SharpZipLib.Tar.TarArchive.rootPath
| private

## ◆ tarIn

TarInputStream ICSharpCode.SharpZipLib.Tar.TarArchive.tarIn
| private

## ◆ tarOut

TarOutputStream ICSharpCode.SharpZipLib.Tar.TarArchive.tarOut
| private

## ◆ userId

int ICSharpCode.SharpZipLib.Tar.TarArchive.userId
| private

## ◆ userName

string ICSharpCode.SharpZipLib.Tar.TarArchive.userName = string.Empty
| private

## Property Documentation

## ◆ ApplyUserInfoOverrides

bool ICSharpCode.SharpZipLib.Tar.TarArchive.ApplyUserInfoOverrides
| get set

Get or set a value indicating if overrides defined by SetUserInfo should be applied.

If overrides are not applied then the values as set in each header will be used.

## ◆ AsciiTranslate

bool ICSharpCode.SharpZipLib.Tar.TarArchive.AsciiTranslate
| get set

Get/set the ascii file translation flag. If ascii file translation is true, then the file is checked to see if it a binary file or not. If the flag is true and the test indicates it is ascii text file, it will be translated. The translation converts the local operating system's concept of line ends into the UNIX line end, '
', which is the defacto standard for a TAR archive. This makes text files compatible with UNIX.

## ◆ GroupId

int ICSharpCode.SharpZipLib.Tar.TarArchive.GroupId
| get

Get the archive group id. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.

Returns
  The current group id.

## ◆ GroupName

string ICSharpCode.SharpZipLib.Tar.TarArchive.GroupName
| get

Get the archive group name. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.

Returns
  The current group name.

## ◆ IsStreamOwner

bool ICSharpCode.SharpZipLib.Tar.TarArchive.IsStreamOwner
| set

Sets the IsStreamOwner property on the underlying stream. Set this to false to prevent the Close of the TarArchive from closing the stream.

## ◆ PathPrefix

string ICSharpCode.SharpZipLib.Tar.TarArchive.PathPrefix
| get set

PathPrefix is added to entry names as they are written if the value is not null. A slash character is appended after PathPrefix.

## ◆ RecordSize

int ICSharpCode.SharpZipLib.Tar.TarArchive.RecordSize
| get

Get the archive's record size. Tar archives are composed of a series of RECORDS each containing a number of BLOCKS. This allowed tar archives to match the IO characteristics of the physical device being used. Archives are expected to be properly "blocked".

Returns
  The record size this archive is using.

## ◆ RootPath

string ICSharpCode.SharpZipLib.Tar.TarArchive.RootPath
| get set

RootPath is removed from entry names if it is found at the beginning of the name.

## ◆ UserId

int ICSharpCode.SharpZipLib.Tar.TarArchive.UserId
| get

Get the archive user id. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.

Returns
  The current user id.

## ◆ UserName

string ICSharpCode.SharpZipLib.Tar.TarArchive.UserName
| get

Get the archive user name. See ApplyUserInfoOverrides for detail on how to allow setting values on a per entry basis.

Returns
  The current user name.

## Event Documentation

## ◆ ProgressMessageEvent

ProgressMessageHandler ICSharpCode.SharpZipLib.Tar.TarArchive.ProgressMessageEvent

Client hook allowing detailed information to be reported during processing.

The documentation for this class was generated from the following file:

- ICSharpCode.SharpZLib/Tar/TarArchive.cs