private bool SaveFile(List<string> Filenames, List<int> ExpIDs, Textures.ITexture2D tex2D, int j)
{
if (cts.IsCancellationRequested)
return false;
PCCObjects.IPCCObject PCC = null;
string currentPCC = Filenames[j];
// KFreon: Skip non existent pccs
if (!File.Exists(currentPCC))
return true;
// KFreon: Fix pathing
string temppath = WhichGame == 1 ? Path.GetDirectoryName(pathBIOGame) : pathBIOGame;
if (!currentPCC.Contains(temppath))
currentPCC = Path.Combine(temppath, currentPCC);
DebugOutput.PrintLn("Now saving pcc: " + currentPCC + "...");
PCC = PCCObjects.Creation.CreatePCCObject(currentPCC, WhichGame);
if (string.Compare(tex2D.texName, PCC.Exports[ExpIDs[j]].ObjectName, true) != 0 || (PCC.Exports[ExpIDs[j]].ClassName != "Texture2D" && PCC.Exports[ExpIDs[j]].ClassName != "LightMapTexture2D" && PCC.Exports[ExpIDs[j]].ClassName != "TextureFlipBook"))
throw new InvalidDataException("Export object has wrong class or name");
Textures.ITexture2D temptex2D = PCC.CreateTexture2D(ExpIDs[j], pathBIOGame);
temptex2D.CopyImgList(tex2D, PCC);
PCC.Exports[ExpIDs[j]].SetData(temptex2D.ToArray(PCC.Exports[ExpIDs[j]].DataOffset, PCC));
PCC.saveToFile(currentPCC);
PCC.Dispose();
return true;
}