Show / Hide Table of Contents

Class TarEntry

This class represents an entry in a Tar archive. It consists of the entry's header, as well as the entry's File. Entries can be instantiated in one of three ways, depending on how they are to be used.

TarEntries that are created from the header bytes read from an archive are instantiated with the TarEntry( byte[] ) constructor. These entries will be used when extracting from or listing the contents of an archive. These entries have their header filled in using the header bytes. They also set the File to null, since they reference an archive entry not a file.

TarEntries that are created from files that are to be written into an archive are instantiated with the CreateEntryFromFile(string) pseudo constructor. These entries have their header filled in using the File's information. They also keep a reference to the File for convenience when writing entries.

Finally, TarEntries can be constructed from nothing but a name. This allows the programmer to construct the entry by hand, for instance when only an InputStream is available for writing to the archive, and the header information is constructed from other information. In this case the header fields are set to defaults and the File is set to null.

TarHeader

Inheritance
System.Object
TarEntry
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ICSharpCode.SharpZipLib.Tar
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class TarEntry

Constructors

| Improve this Doc View Source

TarEntry(TarHeader)

Construct a TarEntry using the header provided

Declaration
public TarEntry(TarHeader header)
Parameters
Type Name Description
TarHeader header

Header details for entry

| Improve this Doc View Source

TarEntry(Byte[])

Construct an entry from an archive's header bytes. File is set to null.

Declaration
[Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")]
public TarEntry(byte[] headerBuffer)
Parameters
Type Name Description
System.Byte[] headerBuffer

The header bytes from a tar archive entry.

| Improve this Doc View Source

TarEntry(Byte[], Encoding)

Construct an entry from an archive's header bytes. File is set to null.

Declaration
public TarEntry(byte[] headerBuffer, Encoding nameEncoding)
Parameters
Type Name Description
System.Byte[] headerBuffer

The header bytes from a tar archive entry.

System.Text.Encoding nameEncoding

The System.Text.Encoding used for the Name fields, or null for ASCII only

Properties

| Improve this Doc View Source

File

Get this entry's file.

Declaration
public string File { get; }
Property Value
Type Description
System.String

This entry's file.

| Improve this Doc View Source

GroupId

Get/set this entry's group id.

Declaration
public int GroupId { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

GroupName

Get/set this entry's group name.

Declaration
public string GroupName { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

IsDirectory

Return true if this entry represents a directory, false otherwise

Declaration
public bool IsDirectory { get; }
Property Value
Type Description
System.Boolean

True if this entry is a directory.

| Improve this Doc View Source

ModTime

Get/Set the modification time for this entry

Declaration
public DateTime ModTime { get; set; }
Property Value
Type Description
System.DateTime
| Improve this Doc View Source

Name

Get/Set this entry's name.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Size

Get/set this entry's recorded file size.

Declaration
public long Size { get; set; }
Property Value
Type Description
System.Int64
| Improve this Doc View Source

TarHeader

Get this entry's header.

Declaration
public TarHeader TarHeader { get; }
Property Value
Type Description
TarHeader

This entry's TarHeader.

| Improve this Doc View Source

UserId

Get/set this entry's user id.

Declaration
public int UserId { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

UserName

Get/set this entry's user name.

Declaration
public string UserName { get; set; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

AdjustEntryName(Byte[], String)

Convenience method that will modify an entry's name directly in place in an entry header buffer byte array.

Declaration
[Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")]
public static void AdjustEntryName(byte[] buffer, string newName)
Parameters
Type Name Description
System.Byte[] buffer

The buffer containing the entry header to modify.

System.String newName

The new name to place into the header buffer.

| Improve this Doc View Source

AdjustEntryName(Byte[], String, Encoding)

Convenience method that will modify an entry's name directly in place in an entry header buffer byte array.

Declaration
public static void AdjustEntryName(byte[] buffer, string newName, Encoding nameEncoding)
Parameters
Type Name Description
System.Byte[] buffer

The buffer containing the entry header to modify.

System.String newName

The new name to place into the header buffer.

System.Text.Encoding nameEncoding

The System.Text.Encoding used for the Name fields, or null for ASCII only

| Improve this Doc View Source

Clone()

Clone this tar entry.

Declaration
public object Clone()
Returns
Type Description
System.Object

Returns a clone of this entry.

| Improve this Doc View Source

CreateEntryFromFile(String)

Construct an entry for a file. File is set to file, and the header is constructed from information from the file.

Declaration
public static TarEntry CreateEntryFromFile(string fileName)
Parameters
Type Name Description
System.String fileName

The file name that the entry represents.

Returns
Type Description
TarEntry

Returns the newly created TarEntry

| Improve this Doc View Source

CreateTarEntry(String)

Construct an entry with only a name. This allows the programmer to construct the entry's header "by hand".

Declaration
public static TarEntry CreateTarEntry(string name)
Parameters
Type Name Description
System.String name

The name to use for the entry

Returns
Type Description
TarEntry

Returns the newly created TarEntry

| Improve this Doc View Source

Equals(Object)

Determine if the two entries are equal. Equality is determined by the header names being equal.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The System.Object to compare with the current Object.

Returns
Type Description
System.Boolean

True if the entries are equal; false if not.

Overrides
System.Object.Equals(System.Object)
| Improve this Doc View Source

GetDirectoryEntries()

Get entries for all files present in this entries directory. If this entry doesnt represent a directory zero entries are returned.

Declaration
public TarEntry[] GetDirectoryEntries()
Returns
Type Description
TarEntry[]

An array of TarEntry's for this entry's children.

| Improve this Doc View Source

GetFileTarHeader(TarHeader, String)

Fill in a TarHeader with information from a File.

Declaration
public void GetFileTarHeader(TarHeader header, string file)
Parameters
Type Name Description
TarHeader header

The TarHeader to fill in.

System.String file

The file from which to get the header information.

| Improve this Doc View Source

GetHashCode()

Derive a Hash value for the current System.Object

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

A Hash code for the current System.Object

Overrides
System.Object.GetHashCode()
| Improve this Doc View Source

IsDescendent(TarEntry)

Determine if the given entry is a descendant of this entry. Descendancy is determined by the name of the descendant starting with this entry's name.

Declaration
public bool IsDescendent(TarEntry toTest)
Parameters
Type Name Description
TarEntry toTest

Entry to be checked as a descendent of this.

Returns
Type Description
System.Boolean

True if entry is a descendant of this.

| Improve this Doc View Source

NameTarHeader(String)

Fill in a TarHeader given only the entry's name.

Declaration
public void NameTarHeader(string name)
Parameters
Type Name Description
System.String name

The tar entry name.

| Improve this Doc View Source

SetIds(Int32, Int32)

Convenience method to set this entry's group and user ids.

Declaration
public void SetIds(int userId, int groupId)
Parameters
Type Name Description
System.Int32 userId

This entry's new user id.

System.Int32 groupId

This entry's new group id.

| Improve this Doc View Source

SetNames(String, String)

Convenience method to set this entry's group and user names.

Declaration
public void SetNames(string userName, string groupName)
Parameters
Type Name Description
System.String userName

This entry's new user name.

System.String groupName

This entry's new group name.

| Improve this Doc View Source

WriteEntryHeader(Byte[])

Write an entry's header information to a header buffer.

Declaration
[Obsolete("No Encoding for Name field is specified, any non-ASCII bytes will be discarded")]
public void WriteEntryHeader(byte[] outBuffer)
Parameters
Type Name Description
System.Byte[] outBuffer

The tar entry header buffer to fill in.

| Improve this Doc View Source

WriteEntryHeader(Byte[], Encoding)

Write an entry's header information to a header buffer.

Declaration
public void WriteEntryHeader(byte[] outBuffer, Encoding nameEncoding)
Parameters
Type Name Description
System.Byte[] outBuffer

The tar entry header buffer to fill in.

System.Text.Encoding nameEncoding

The System.Text.Encoding used for the Name fields, or null for ASCII only

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000-2022 SharpZipLib Contributors