30 using System.Reflection;
 
   34 namespace OpenSim.Framework.Serialization
 
   48             TYPE_SYMBOLIC_LINK = 3,
 
   49             TYPE_CHAR_SPECIAL = 4,
 
   50             TYPE_BLOCK_SPECIAL = 5,
 
   53             TYPE_CONTIGUOUS_FILE = 8,
 
   59         protected BinaryReader 
m_br;
 
   64         protected static char[] m_nullCharArray = 
new char[] { 
'\0' };
 
   68         protected static char[] m_spaceCharArray = 
new char[] { 
' ' };
 
   76             m_br = 
new BinaryReader(s);
 
   86             filePath = String.Empty;
 
   87             entryType = TarEntryType.TYPE_UNKNOWN;
 
   93             entryType = header.EntryType;
 
   94             filePath = header.FilePath;
 
  104             byte[] header = m_br.ReadBytes(512);
 
  107             if (header.Length == 0)
 
  118             if (header[156] == (byte)
'L')
 
  120                 int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11);
 
  121                 tarHeader.FilePath = Encoding.ASCII.GetString(ReadData(longNameLength));
 
  123                 header = m_br.ReadBytes(512);
 
  127                 tarHeader.FilePath = Encoding.ASCII.GetString(header, 0, 100);
 
  128                 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
 
  132             tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
 
  137                     tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
 
  140                     tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
 
  143                     tarHeader.EntryType = TarEntryType.TYPE_HARD_LINK;
 
  146                     tarHeader.EntryType = TarEntryType.TYPE_SYMBOLIC_LINK;
 
  149                     tarHeader.EntryType = TarEntryType.TYPE_CHAR_SPECIAL;
 
  152                     tarHeader.EntryType = TarEntryType.TYPE_BLOCK_SPECIAL;
 
  155                     tarHeader.EntryType = TarEntryType.TYPE_DIRECTORY;
 
  158                     tarHeader.EntryType = TarEntryType.TYPE_FIFO;
 
  161                     tarHeader.EntryType = TarEntryType.TYPE_CONTIGUOUS_FILE;
 
  175             byte[] data = m_br.ReadBytes(fileSize);
 
  180             if (fileSize % 512 != 0)
 
  182                 int paddingLeft = 512 - (fileSize % 512);
 
  186                 m_br.ReadBytes(paddingLeft);
 
  206             string oString = Encoding.ASCII.GetString(bytes, startIndex, count).TrimStart(m_spaceCharArray);
 
  210             foreach (
char c 
in oString)
 
Temporary code to do the bare minimum required to read a tar archive for our purposes ...
 
static int ConvertOctalBytesToDecimal(byte[] bytes, int startIndex, int count)
Convert octal bytes to a decimal representation 
 
byte[] ReadData(int fileSize)
Read data following a header 
 
BinaryReader m_br
Binary reader for the underlying stream 
 
TarArchiveReader(Stream s)
Generate a tar reader which reads from the given stream. 
 
TarHeader ReadHeader()
Read the next 512 byte chunk of data as a tar header. 
 
byte[] ReadEntry(out string filePath, out TarEntryType entryType)
Read the next entry in the tar file.