ME3Explorer.Texplorer2.SaveFile C# (CSharp) Method

SaveFile() private method

private SaveFile ( List Filenames, List ExpIDs, KFreonLib.Textures tex2D, int j ) : bool
Filenames List
ExpIDs List
tex2D KFreonLib.Textures
j int
return bool
        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;
        }
Texplorer2