diff options
author | Justin Clarke Casey | 2009-03-04 18:33:05 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-03-04 18:33:05 +0000 |
commit | b57497fd41ad4cc56af40139ba940b5a4bbd47a6 (patch) | |
tree | 58bebd6dc61420dd01139cbddde61c955f63c9d9 /OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs | |
parent | IObjectFace needs to be public to compile. (diff) | |
download | opensim-SC_OLD-b57497fd41ad4cc56af40139ba940b5a4bbd47a6.zip opensim-SC_OLD-b57497fd41ad4cc56af40139ba940b5a4bbd47a6.tar.gz opensim-SC_OLD-b57497fd41ad4cc56af40139ba940b5a4bbd47a6.tar.bz2 opensim-SC_OLD-b57497fd41ad4cc56af40139ba940b5a4bbd47a6.tar.xz |
* Add gnu tar format long file name support to tar reading and writing.
* Not actually tested yet though existing code which doesn't require long file names looks fine
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs index a1884d5..afe5938 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs | |||
@@ -27,7 +27,9 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | ||
30 | using System.Text; | 31 | using System.Text; |
32 | using log4net; | ||
31 | 33 | ||
32 | namespace OpenSim.Region.CoreModules.World.Archiver | 34 | namespace OpenSim.Region.CoreModules.World.Archiver |
33 | { | 35 | { |
@@ -36,7 +38,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
36 | /// </summary> | 38 | /// </summary> |
37 | public class TarArchiveReader | 39 | public class TarArchiveReader |
38 | { | 40 | { |
39 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | 42 | ||
41 | public enum TarEntryType | 43 | public enum TarEntryType |
42 | { | 44 | { |
@@ -116,12 +118,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
116 | // If we've reached the end of the archive we'll be in null block territory, which means | 118 | // If we've reached the end of the archive we'll be in null block territory, which means |
117 | // the next byte will be 0 | 119 | // the next byte will be 0 |
118 | if (header[0] == 0) | 120 | if (header[0] == 0) |
119 | return null; | 121 | return null; |
120 | 122 | ||
121 | TarHeader tarHeader = new TarHeader(); | 123 | TarHeader tarHeader = new TarHeader(); |
122 | 124 | ||
123 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | 125 | // If we're looking at a GNU tar long link then extract the long name and pull up the next header |
124 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); | 126 | if (header[156] == (byte)'L') |
127 | { | ||
128 | int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); | ||
129 | tarHeader.FilePath = m_asciiEncoding.GetString(m_br.ReadBytes(longNameLength)); | ||
130 | m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); | ||
131 | header = m_br.ReadBytes(512); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | ||
136 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); | ||
137 | } | ||
138 | |||
125 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); | 139 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); |
126 | 140 | ||
127 | switch (header[156]) | 141 | switch (header[156]) |