ace/Source/ACE.DatLoader/PortalDatDatabase.cs
Ty Conner c4a3da0b10 Full reset of repo (#327)
* Full Wipe

* Restored git settings

* Restored Root folder

* Restored Source & Database
2017-05-05 10:26:35 -04:00

42 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ACE.DatLoader
{
public class PortalDatDatabase : DatDatabase
{
public PortalDatDatabase(string filename) : base(filename, DatDatabaseType.Portal)
{
}
public void ExtractCategorizedContents(string path)
{
string thisFolder = null;
foreach (KeyValuePair<uint, DatFile> entry in this.AllFiles)
{
if (entry.Value.GetFileType() != null)
thisFolder = Path.Combine(path, entry.Value.GetFileType().ToString());
else
thisFolder = Path.Combine(path, "UnknownType");
if (!Directory.Exists(thisFolder))
{
Directory.CreateDirectory(thisFolder);
}
string hex = entry.Value.ObjectId.ToString("X8");
string thisFile = Path.Combine(thisFolder, hex + ".bin");
// Use the DatReader to get the file data
DatReader dr = this.GetReaderForFile(entry.Value.ObjectId);
File.WriteAllBytes(thisFile, dr.Buffer);
}
}
}
}