Skip to content

Container Files

Phil edited this page Dec 29, 2018 · 2 revisions

Container Examples

Namespace

using ShenmueDKSharp.Files.Containers;

AFS Examples

Unpacking

public void ExtractAFS(string afsFilepath, string folder)
{
  AFS afs = new AFS(afsFilepath);
  afs.Unpack(folder);
}

Unpacking with IDX

public void ExtractAFSWithIDX(string afsFilepath, string idxFilepath, string folder)
{
  AFS afs = new AFS(afsFilepath);
  IDX idx = new IDX(idxFilepath);
  afs.MapIDXFile(idx);
  afs.Unpack(folder);
}

Packing

public void PackAFS(string afsFilepath, List<string> filepaths)
{
  AFS afs = new AFS();
  afs.Pack(filepaths);
  afs.Write(afsFilepath);
}

GZip Examples

Unpacking

public void ExtractGZ(string gzFilepath, string folder)
{
  GZ gz = new GZ(gzFilepath);
  gz.Unpack(folder);
}

Packing

public void PackGZ(string gzFilepath, string filepath)
{
  GZ gz = new GZ();
  gz.Pack(filepath);
  gz.Write(gzFilepath);
}

IPAC Examples

Unpacking

public void ExtractIPAC(string ipacFilepath, string folder)
{
  IPAC ipac= new IPAC(ipacFilepath);
  ipac.Unpack(folder);
}

Packing

public void PackIPAC(string ipacFilepath, List<string> filepaths)
{
  IPAC ipac = new IPAC();
  ipac.Pack(filepaths);
  ipac.Write(gzFilepath);
}

PKF Examples

Unpacking

public void ExtractPKF(string pkfFilepath, string folder)
{
  PKF pkf = new PKF(pkfFilepath);
  pkf.Unpack(folder);
}

Packing

public void PackPKF(string pkfFilepath, List<string> filepaths)
{
  PKF pkf = new PKF();
  pkf.Pack(filepaths);
  pkf.Write(pkfFilepath);
}

PKS Examples

Unpacking

public void ExtractPKS(string pksFilepath, string folder)
{
  PKS pks = new PKS(pksFilepath);
  pks.Unpack(folder);
}

Packing

public void PackPKS(string pksFilepath, List<string> filepaths)
{
  PKS pks = new PKS();
  pks.Pack(filepaths);
  pks.Write(pksFilepath);
}

SPR Examples

Unpacking

public void ExtractSPR(string sprFilepath, string folder)
{
  SPR spr = new SPR(sprFilepath);
  spr.Unpack(folder);
}

Packing

public void PackSPR(string sprFilepath, List<string> filepaths)
{
  SPR spr = new SPR();
  spr.Pack(filepaths);
  spr.Write(sprFilepath);
}

TAD/TAC Examples

Unpacking

public void ExtractTAC(string tadFilepath, string tacFilepath, string folder)
{
  TAD tad = new TAD(tadFilepath);
  tad.Unpack(tacFilepath, folder);
}

Packing

public void PackTAC(string tadFilepath, string tacFilepath, List<TADEntry> entries)
{
  TAD tad = new TAD();
  tad.Pack(tacFilepath, entries);
  tad.Write(tadFilepath);
}

Extract single file from TAC

public void ExtractFile(string tadFilepath, string searchFile, string outputFile)
{
  TAD tad = new TAD(tadFilepath);
  TAC tac = new TAC(tad);
  byte[] fileBuffer = tac.GetFileBuffer(searchFile);
  using(FileStream stream = new FileStream(outputFile, FileMode.Create))
  {
    stream.Write(fileBuffer, 0, fileBuffer.Length);
  }
}