Moving TarArchive to OpenSim.Framework.Archive

We now build OpenSim.Framework.Archive.dll which aims to contain code
used for archiving various things in OpenSim. Also remove trailing
whitespace.
0.6.5-rc1
Mike Mazur 2009-03-12 06:03:59 +00:00
parent 4eba67175d
commit f784620780
11 changed files with 60 additions and 29 deletions

View File

@ -31,7 +31,7 @@ using System.Reflection;
using System.Text;
using log4net;
namespace OpenSim.Region.CoreModules.World.Archiver
namespace OpenSim.Framework.Archive
{
/// <summary>
/// Temporary code to do the bare minimum required to read a tar archive for our purposes
@ -39,8 +39,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public class TarArchiveReader
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public enum TarEntryType
public enum TarEntryType
{
TYPE_UNKNOWN = 0,
TYPE_NORMAL_FILE = 1,
@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
return null;
entryType = header.EntryType;
filePath = header.FilePath;
filePath = header.FilePath;
return ReadData(header.FileSize);
}
@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// If we've reached the end of the archive we'll be in null block territory, which means
// the next byte will be 0
if (header[0] == 0)
return null;
return null;
TarHeader tarHeader = new TarHeader();
@ -117,15 +117,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
header = m_br.ReadBytes(512);
}
else
{
{
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
//m_log.DebugFormat("[TAR ARCHIVE READER]: Got short file name {0}", tarHeader.FilePath);
}
tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
switch (header[156])
switch (header[156])
{
case 0:
tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
@ -154,11 +154,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
case (byte)'7':
tarHeader.EntryType = TarEntryType.TYPE_CONTIGUOUS_FILE;
break;
}
}
return tarHeader;
}
/// <summary>
/// Read data following a header
/// </summary>
@ -179,7 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_br.ReadBytes(paddingLeft);
}
return data;
}

View File

@ -30,7 +30,7 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
namespace OpenSim.Region.CoreModules.World.Archiver
namespace OpenSim.Framework.Archive
{
/// <summary>
/// Temporary code to produce a tar archive in tar v7 format
@ -45,12 +45,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// Binary writer for the underlying stream
/// </summary>
protected BinaryWriter m_bw;
public TarArchiveWriter(Stream s)
{
m_bw = new BinaryWriter(s);
}
/// <summary>
/// Write a directory entry to the tar archive. We can only handle one path level right now!
/// </summary>
@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
WriteFile(dirName, new byte[0]);
}
/// <summary>
/// Write a file to the tar archive
/// </summary>
@ -83,9 +83,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
if (filePath.Length > 100)
WriteEntry("././@LongLink", m_asciiEncoding.GetBytes(filePath), 'L');
char fileType;
if (filePath.EndsWith("/"))
{
fileType = '5';
@ -93,11 +93,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
else
{
fileType = '0';
}
}
WriteEntry(filePath, data, fileType);
}
/// <summary>
/// Finish writing the raw tar archive data to a stream. The stream will be closed on completion.
/// </summary>
@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public void Close()
{
//m_log.Debug("[TAR ARCHIVE WRITER]: Writing final consecutive 0 blocks");
// Write two consecutive 0 blocks to end the archive
byte[] finalZeroPadding = new byte[1024];
m_bw.Write(finalZeroPadding);
@ -133,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
byte[] oBytes = m_asciiEncoding.GetBytes(oString);
return oBytes;
}
}
/// <summary>
/// Write a particular entry
@ -211,7 +211,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
byte[] padding = new byte[paddingRequired];
m_bw.Write(padding);
}
}
}
}
}
}

View File

@ -33,8 +33,8 @@ using System.Xml;
using System.Reflection;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Framework.Servers;
using OpenSim.Region.CoreModules.World.Archiver;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using log4net;

View File

@ -35,6 +35,7 @@ using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.CoreModules.World.Archiver;

View File

@ -34,6 +34,7 @@ using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.CoreModules.World.Archiver;

View File

@ -34,6 +34,7 @@ using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Data;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
@ -182,4 +183,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
// TODO: Test presence of more files and contents of files.
}
}
}
}

View File

@ -35,6 +35,7 @@ using System.Text;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Interfaces;

View File

@ -33,6 +33,7 @@ using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;

View File

@ -32,6 +32,7 @@ using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
namespace OpenSim.Region.CoreModules.World.Archiver
{

View File

@ -33,6 +33,7 @@ using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Archive;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Scenes;
@ -303,4 +304,4 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
}
}
}
}
}

View File

@ -105,6 +105,27 @@
</Files>
</Project>
<Project name="OpenSim.Framework.Archive" path="OpenSim/Framework/Archive" type="Library">
<Configuration name="Debug">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<Configuration name="Release">
<Options>
<OutputPath>../../../bin/</OutputPath>
</Options>
</Configuration>
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="log4net.dll"/>
<Files>
<Match pattern="*.cs" recurse="true"/>
</Files>
</Project>
<Project name="OpenSim.Framework.Statistics" path="OpenSim/Framework/Statistics" type="Library">
<Configuration name="Debug">
<Options>
@ -1098,6 +1119,7 @@
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Data" />
<Reference name="OpenSim.Region.Framework" />
<Reference name="OpenSim.Framework.Archive"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Framework.Statistics"/>
@ -1138,11 +1160,12 @@
<Reference name="OpenMetaverseTypes"/>
<Reference name="OpenMetaverse.StructuredData"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Archive"/>
<Reference name="OpenSim.Framework.Servers"/>
<Reference name="OpenSim.Grid.AssetInventoryServer" />
<Reference name="log4net"/>
<!-- Needed for TarArchiver. Hopefully it can be moved to Framework or something so we don't depend on Region DLLs. -->
<!-- Needed for InventoryArchiveConstants. Hopefully it can be moved to Framework or something so we don't depend on Region DLLs. -->
<Reference name="OpenSim.Region.CoreModules"/>
<Files>
@ -2951,6 +2974,7 @@
<Reference name="OpenMetaverse.dll"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Archive"/>
<Reference name="OpenSim.Framework.Communications"/>
<Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers"/>