diff options
author | Justin Clarke Casey | 2009-03-04 20:31:03 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-03-04 20:31:03 +0000 |
commit | b52ac542ade6af9ad404dcebf68be3bef769b0e1 (patch) | |
tree | 2a304eb111ed61080c04893f14f89858bedda2e2 /OpenSim/Region/CoreModules/World/Archiver | |
parent | * Whoops. Left MiniModule enabled to anyone. (potential security risk). Disab... (diff) | |
download | opensim-SC-b52ac542ade6af9ad404dcebf68be3bef769b0e1.zip opensim-SC-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.gz opensim-SC-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.bz2 opensim-SC-b52ac542ade6af9ad404dcebf68be3bef769b0e1.tar.xz |
* Add the abilty to load and save iar item nodes where folders have identical names
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs index afe5938..19d2629 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/TarArchiveReader.cs | |||
@@ -89,22 +89,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
89 | return null; | 89 | return null; |
90 | 90 | ||
91 | entryType = header.EntryType; | 91 | entryType = header.EntryType; |
92 | filePath = header.FilePath; | 92 | filePath = header.FilePath; |
93 | byte[] data = m_br.ReadBytes(header.FileSize); | 93 | return ReadData(header.FileSize); |
94 | |||
95 | //m_log.DebugFormat("[TAR ARCHIVE READER]: filePath {0}, fileSize {1}", filePath, header.FileSize); | ||
96 | |||
97 | // Read the rest of the empty padding in the 512 byte block | ||
98 | if (header.FileSize % 512 != 0) | ||
99 | { | ||
100 | int paddingLeft = 512 - (header.FileSize % 512); | ||
101 | |||
102 | //m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft); | ||
103 | |||
104 | m_br.ReadBytes(paddingLeft); | ||
105 | } | ||
106 | |||
107 | return data; | ||
108 | } | 94 | } |
109 | 95 | ||
110 | /// <summary> | 96 | /// <summary> |
@@ -126,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
126 | if (header[156] == (byte)'L') | 112 | if (header[156] == (byte)'L') |
127 | { | 113 | { |
128 | int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); | 114 | int longNameLength = ConvertOctalBytesToDecimal(header, 124, 11); |
129 | tarHeader.FilePath = m_asciiEncoding.GetString(m_br.ReadBytes(longNameLength)); | 115 | tarHeader.FilePath = m_asciiEncoding.GetString(ReadData(longNameLength)); |
130 | m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); | 116 | m_log.DebugFormat("[TAR ARCHIVE READER]: Got long file name {0}", tarHeader.FilePath); |
131 | header = m_br.ReadBytes(512); | 117 | header = m_br.ReadBytes(512); |
132 | } | 118 | } |
@@ -134,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
134 | { | 120 | { |
135 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | 121 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); |
136 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); | 122 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); |
123 | m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath); | ||
137 | } | 124 | } |
138 | 125 | ||
139 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); | 126 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); |
@@ -171,6 +158,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
171 | 158 | ||
172 | return tarHeader; | 159 | return tarHeader; |
173 | } | 160 | } |
161 | |||
162 | /// <summary> | ||
163 | /// Read data following a header | ||
164 | /// </summary> | ||
165 | /// <param name="fileSize"></param> | ||
166 | /// <returns></returns> | ||
167 | protected byte[] ReadData(int fileSize) | ||
168 | { | ||
169 | byte[] data = m_br.ReadBytes(fileSize); | ||
170 | |||
171 | m_log.DebugFormat("[TAR ARCHIVE READER]: fileSize {0}", fileSize); | ||
172 | |||
173 | // Read the rest of the empty padding in the 512 byte block | ||
174 | if (fileSize % 512 != 0) | ||
175 | { | ||
176 | int paddingLeft = 512 - (fileSize % 512); | ||
177 | |||
178 | m_log.DebugFormat("[TAR ARCHIVE READER]: Reading {0} padding bytes", paddingLeft); | ||
179 | |||
180 | m_br.ReadBytes(paddingLeft); | ||
181 | } | ||
182 | |||
183 | return data; | ||
184 | } | ||
174 | 185 | ||
175 | public void Close() | 186 | public void Close() |
176 | { | 187 | { |