* Put textures into a separate assets/ directory in the opensim archive

* Fix nre where the asset couldn't be found
* Not ready yet
0.6.0-stable
Justin Clarke Casey 2008-05-28 16:37:43 +00:00
parent 7ddf183da4
commit 51a43b30a2
2 changed files with 37 additions and 6 deletions

View File

@ -107,9 +107,19 @@ namespace OpenSim.Region.Environment
archive.AddFile("prims.xml", m_serializedEntities);
// It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
//archive.AddDir("assets");
foreach (LLUUID uuid in assets.Keys)
{
archive.AddFile(uuid.ToString() + ".jp2", assets[uuid].Data);
if (assets[uuid] != null)
{
archive.AddFile("assets/" + uuid.ToString() + ".jp2", assets[uuid].Data);
}
else
{
m_log.DebugFormat("[ARCHIVER]: Could not find asset {0} to archive", uuid);
}
}
archive.WriteTar(m_savePath);

View File

@ -46,6 +46,19 @@ namespace OpenSim.Region.Environment
protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
/// <summary>
/// Add a directory to the tar archive. We can only handle one path level right now!
/// </summary>
/// <param name="dirName"></param>
public void AddDir(string dirName)
{
// Directories are signalled by a final /
if (!dirName.EndsWith("/"))
dirName += "/";
AddFile(dirName, new byte[0]);
}
/// <summary>
/// Add a file to the tar archive
/// </summary>
@ -88,7 +101,7 @@ namespace OpenSim.Region.Environment
Array.Copy(nameBytes, header, nameSize);
// file mode (8)
byte[] modeBytes = m_asciiEncoding.GetBytes("0000644");
byte[] modeBytes = m_asciiEncoding.GetBytes("0000755");
Array.Copy(modeBytes, 0, header, 100, 7);
// owner user id (8)
@ -113,7 +126,14 @@ namespace OpenSim.Region.Environment
// link indicator (1)
//header[156] = m_asciiEncoding.GetBytes("0")[0];
header[156] = 0;
if (filePath.EndsWith("/"))
{
header[156] = m_asciiEncoding.GetBytes("5")[0];
}
else
{
header[156] = 0;
}
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 329, 7);
Array.Copy(m_asciiEncoding.GetBytes("0000000"), 0, header, 337, 7);
@ -142,9 +162,10 @@ namespace OpenSim.Region.Environment
// Write out data
bw.Write(data);
int paddingRequired = 512 - (data.Length % 512);
if (paddingRequired > 0)
if (data.Length % 512 != 0)
{
int paddingRequired = 512 - (data.Length % 512);
m_log.DebugFormat("Padding data with {0} bytes", paddingRequired);
byte[] padding = new byte[paddingRequired];