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.
TarHeaderInheritance
Inherited Members
Namespace: ICSharpCode.SharpZipLib.Tar
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class TarEntry
Constructors
| Improve this Doc View SourceTarEntry(TarHeader)
Construct a TarEntry using the header
provided
Declaration
public TarEntry(TarHeader header)
Parameters
Type | Name | Description |
---|---|---|
TarHeader | header | Header details for entry |
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. |
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 SourceFile
Get this entry's file.
Declaration
public string File { get; }
Property Value
Type | Description |
---|---|
System.String | This entry's file. |
GroupId
Get/set this entry's group id.
Declaration
public int GroupId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
GroupName
Get/set this entry's group name.
Declaration
public string GroupName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
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. |
ModTime
Get/Set the modification time for this entry
Declaration
public DateTime ModTime { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
Name
Get/Set this entry's name.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Size
Get/set this entry's recorded file size.
Declaration
public long Size { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
TarHeader
Get this entry's header.
Declaration
public TarHeader TarHeader { get; }
Property Value
Type | Description |
---|---|
TarHeader | This entry's TarHeader. |
UserId
Get/set this entry's user id.
Declaration
public int UserId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
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 SourceAdjustEntryName(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. |
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 |
Clone()
Clone this tar entry.
Declaration
public object Clone()
Returns
Type | Description |
---|---|
System.Object | Returns a clone of this entry. |
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 |
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 |
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
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. |
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. |
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
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. |
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. |
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. |
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. |
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. |
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 |