private void rPFFilesToolStripMenuItem_Click(object sender, EventArgs e) { var watch = Stopwatch.StartNew(); if (folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) { new Thread(() => { Thread.CurrentThread.IsBackground = true; string[] rpfFiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.rpf", SearchOption.AllDirectories); foreach (string file in rpfFiles) { TimeLabel.Text = "Scanning RPFs and Extracting Files ..."; RpfFile rpf = new RpfFile(file, Path.GetDirectoryName(file)); try { rpf.ScanStructure(null, null); var fileTypes = new List <string>() { ".ybn", ".ymap" }; RPFFunctions.SearchRPF(rpf, file, CurrentList, fileTypes); var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } catch (Exception) { MessageBox.Show("Error can't read " + file + ".\nThis file has been skipped.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } StringFunctions.SetCountAndTime(watch.ElapsedMilliseconds, TimeLabel, CurrentList, FilesAddedLabel, startButton); }).Start(); } }
public RpfFile FindRpfFile(string path) { RpfFile file = null; //check the dictionary if (EnableMods && ModRpfDict.TryGetValue(path, out file)) { return(file); } if (RpfDict.TryGetValue(path, out file)) { return(file); } string lpath = path.ToLower(); //try look at names etc foreach (RpfFile tfile in AllRpfs) { if (tfile.NameLower == lpath) { return(tfile); } if (tfile.Path == lpath) { return(tfile); } } return(file); }
public void Init(string folder, Action <string> updateStatus, Action <string> errorLog, bool rootOnly = false) { UpdateStatus = updateStatus; ErrorLog = errorLog; string replpath = folder + "\\"; var sopt = rootOnly ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories; string[] allfiles = Directory.GetFiles(folder, "*.rpf", sopt); BaseRpfs = new List <RpfFile>(); ModRpfs = new List <RpfFile>(); DlcRpfs = new List <RpfFile>(); AllRpfs = new List <RpfFile>(); DlcNoModRpfs = new List <RpfFile>(); AllNoModRpfs = new List <RpfFile>(); RpfDict = new Dictionary <string, RpfFile>(); EntryDict = new Dictionary <string, RpfEntry>(); ModRpfDict = new Dictionary <string, RpfFile>(); ModEntryDict = new Dictionary <string, RpfEntry>(); foreach (string rpfpath in allfiles) { try { RpfFile rf = new RpfFile(rpfpath, rpfpath.Replace(replpath, "")); if (ExcludePaths != null) { bool excl = false; for (int i = 0; i < ExcludePaths.Length; i++) { if (rf.Path.StartsWith(ExcludePaths[i])) { excl = true; break; } } if (excl) { continue; //skip files in exclude paths. } } rf.ScanStructure(updateStatus, errorLog); AddRpfFile(rf, false, false); } catch (Exception ex) { errorLog(rpfpath + ": " + ex.ToString()); } } updateStatus("Building jenkindex..."); BuildBaseJenkIndex(); updateStatus("Scan complete"); IsInited = true; }
public static (RpfDirectoryEntry, byte[]) GetFileData(RpfFile CurrentRPF, string file) { foreach (RpfEntry RPFFile in CurrentRPF.AllEntries) { if (RPFFile.Name == file) { byte[] oldData = SaveResourceAsBytes(RPFFile); if (oldData != null) { return(RPFFile.Parent, oldData); } } } foreach (RpfFile RPFs in CurrentRPF.Children) { RpfDirectoryEntry ChildRpfParent; byte[] finalFile; (ChildRpfParent, finalFile) = GetFileData(RPFs, file); if (finalFile != null) { return(ChildRpfParent, finalFile); } } return(null, null); }
private void AddScannedFile(RpfFile file, TreeNode node, bool addToList = false) { try { if (InvokeRequired) { Invoke(new Action(() => { AddScannedFile(file, node, addToList); })); } else { var cnode = AddFileNode(file, node); if (FlatStructure) { cnode = null; } foreach (RpfFile cfile in file.Children) { AddScannedFile(cfile, cnode, addToList); } if (addToList) { ScannedFiles.Add(file); } } } catch { } }
private void rPFFilesToolStripMenuItem_Click(object sender, EventArgs e) { timerTime = DateTime.Now; watch = new System.Threading.Timer(Tick, null, 0, 10); if (folderBrowserDialog1.ShowDialog(this) == DialogResult.OK) { new Thread(() => { Thread.CurrentThread.IsBackground = true; string[] rpfFiles = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.rpf", SearchOption.AllDirectories); foreach (string file in rpfFiles) { TimeLabel.Text = "Scanning RPFs and Extracting Files ..."; RpfFile rpf = new RpfFile(file, Path.GetDirectoryName(file)); try { rpf.ScanStructure(null, null); var fileTypes = new List <string>() { ".ybn", ".ymap" }; RPFFunctions.SearchRPF(rpf, file, CurrentList, fileTypes); } catch (Exception) { MessageBox.Show("Error can't read " + file + ".\nThis file has been skipped.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } StringFunctions.SetCount(CurrentList, FilesAddedLabel, startButton); watch.Dispose(); }).Start(); } }
private void AddRpfDatRels(RpfFile rpffile, Dictionary <uint, RpfFileEntry> datrelentries) { if (rpffile.AllEntries == null) { return; } foreach (var entry in rpffile.AllEntries) { if (entry is RpfFileEntry) { RpfFileEntry fentry = entry as RpfFileEntry; //if (entry.NameLower.EndsWith(".rel")) //{ // datrelentries[entry.NameHash] = fentry; //} if (entry.NameLower.EndsWith(".dat54.rel")) { datrelentries[entry.NameHash] = fentry; } if (entry.NameLower.EndsWith(".dat151.rel")) { datrelentries[entry.NameHash] = fentry; } } } }
public void Load(byte[] data) { //direct load from a raw, compressed ytyp file (openIV-compatible format) RpfFile.LoadResourceFile(this, data, 2); Loaded = true; }
public void Load(byte[] data) { //direct load from a raw, compressed ydd file RpfFile.LoadResourceFile(this, data, 165); Loaded = true; }
private bool SaveToRPF(string txt) { if (!(exploreForm?.EditMode ?? false)) { return(false); } if (rpfFileEntry?.Parent == null) { return(false); } byte[] data = null; data = Encoding.UTF8.GetBytes(txt); if (data == null) { MessageBox.Show("Unspecified error - data was null!", "Cannot save file"); return(false); } if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) { if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false);//that was a close one } } try { if (!(exploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) { return(false); } var newentry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); if (newentry != rpfFileEntry) { } rpfFileEntry = newentry; exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... modified = false; StatusLabel.Text = "Text file saved successfully at " + DateTime.Now.ToString(); return(true); //victory! } catch (Exception ex) { MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error"); } return(false); }
private void ExtractScriptsButton_Click(object sender, EventArgs e) { if (InProgress) { return; } if (!KeysLoaded) { MessageBox.Show("Please scan a GTA 5 exe dump for keys first, or include key files in this app's folder!"); return; } if (!Directory.Exists(FolderTextBox.Text)) { MessageBox.Show("Folder doesn't exist: " + FolderTextBox.Text); return; } if (!Directory.Exists(OutputFolderTextBox.Text)) { MessageBox.Show("Folder doesn't exist: " + OutputFolderTextBox.Text); return; } if (Directory.GetFiles(OutputFolderTextBox.Text, "*.ysc", SearchOption.AllDirectories).Length > 0) { if (MessageBox.Show("Output folder already contains .ysc files. Are you sure you want to continue?", "Output folder already contains .ysc files", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } InProgress = true; AbortOperation = false; string searchpath = FolderTextBox.Text; string outputpath = OutputFolderTextBox.Text; string replpath = searchpath + "\\"; Task.Run(() => { UpdateExtractStatus("Keys loaded."); string[] allfiles = Directory.GetFiles(searchpath, "*.rpf", SearchOption.AllDirectories); foreach (string rpfpath in allfiles) { RpfFile rf = new RpfFile(rpfpath, rpfpath.Replace(replpath, "")); UpdateExtractStatus("Searching " + rf.Name + "..."); rf.ExtractScripts(outputpath, UpdateExtractStatus); } UpdateExtractStatus("Complete."); InProgress = false; }); }
public static void AddFileBackToRPF(RpfDirectoryEntry RPFDirectory, string filename, byte[] newData) { if (Regex.Matches(filename, ".rpf").Count > 1) { string topRPF = StringFunctions.TopMostRPF(filename); RpfFile CurrentRpf = new RpfFile(topRPF, topRPF); CurrentRpf.ScanStructure(null, null); DefragmentChildren(CurrentRpf, filename, newData, RPFDirectory); } else { RpfFile.CreateFile(RPFDirectory, Path.GetFileName(filename), newData, true); RpfFile CurrentRpf = new RpfFile(Path.GetDirectoryName(filename), Path.GetDirectoryName(filename)); RpfFile.Defragment(CurrentRpf); } }
public static void DefragmentChildren(RpfFile CurrentRpf, string file, byte[] newData, RpfDirectoryEntry RPFDirectory) { foreach (RpfEntry RPFFile in CurrentRpf.AllEntries) { if (RPFFile.Name == Path.GetFileName(file)) { RpfFile.CreateFile(RPFDirectory, Path.GetFileName(file), newData, true); RpfFile.Defragment(CurrentRpf); break; } } foreach (RpfFile RPFs in CurrentRpf.Children) { DefragmentChildren(RPFs, file, newData, RPFDirectory); } }
public static void ProcessFile(string path) { if (path.EndsWith(".rpf")) { RpfFile rpf = new RpfFile(path, path); if (rpf.ScanStructure(null, null)) { ExtractFilesInRPF(rpf, "./rpf-extracted/"); // Move ProcessDirectory("./rpf-extracted", true); } else { Console.WriteLine("Input file is invalid ..."); } } }
private void addItemsToolStripMenuItem_Click(object sender, EventArgs e) { var watch = Stopwatch.StartNew(); if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (string file in openFileDialog1.FileNames) { if (file.EndsWith(".rpf")) { TimeLabel.Text = "Scanning RPFs and Extracting Files ..."; RpfFile rpf = new RpfFile(file, Path.GetDirectoryName(file)); try { rpf.ScanStructure(null, null); var fileTypes = new List <string>() { ".ybn", ".ydr", ".yft", ".ydd" }; RPFFunctions.SearchRPF(rpf, file, CurrentList, fileTypes); } catch (Exception) { MessageBox.Show("Error can't read " + file + ".\nThis file has been skipped.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (!StringFunctions.DoesItemExist(CurrentList, file)) { CurrentList.Items.Add(file); } } var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } StringFunctions.SetCountAndTime(watch.ElapsedMilliseconds, TimeLabel, CurrentList, FilesAddedLabel, startButton); }).Start(); } }
private void addItemsToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog(this) == DialogResult.OK) { timerTime = DateTime.Now; watch = new System.Threading.Timer(Tick, null, 0, 10); new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (string file in openFileDialog1.FileNames) { if (file.EndsWith(".rpf")) { TimeLabel.Text = "Scanning RPFs and Extracting Files ..."; RpfFile rpf = new RpfFile(file, Path.GetDirectoryName(file)); try { rpf.ScanStructure(null, null); var fileTypes = new List <string>() { ".ybn", ".ymap" }; RPFFunctions.SearchRPF(rpf, file, CurrentList, fileTypes); } catch (Exception) { MessageBox.Show("Error can't read " + file + ".\nThis file has been skipped.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (!StringFunctions.DoesItemExist(CurrentList, file)) { CurrentList.Items.Add(file); } } } StringFunctions.SetCount(CurrentList, FilesAddedLabel, startButton); watch.Dispose(); }).Start(); } }
public static void SearchRPF(RpfFile rpf, string file, ListBox CurrentList, List <string> FileTypes) { foreach (RpfEntry RPFFile in rpf.AllEntries) { foreach (string item in FileTypes) { if (RPFFile.Name.EndsWith(item)) { if (!StringFunctions.DoesItemExist(CurrentList, Path.Combine(file, RPFFile.Name))) { CurrentList.Items.Add(Path.Combine(file, RPFFile.Name)); } } } } foreach (RpfFile RPFs in rpf.Children) { SearchRPF(RPFs, file + "\\" + RPFs.Name, CurrentList, FileTypes); } }
private void CurrentList_DragDrop(object sender, DragEventArgs e) { new Thread(() => { timerTime = DateTime.Now; watch = new System.Threading.Timer(Tick, null, 0, 10); Thread.CurrentThread.IsBackground = true; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { if (file.EndsWith("ybn") || file.EndsWith("ymap")) { if (!StringFunctions.DoesItemExist(CurrentList, file)) { CurrentList.Items.Add(file); } else if (file.EndsWith("rpf")) { TimeLabel.Text = "Scanning RPFs and Extracting Files ..."; RpfFile rpf = new RpfFile(file, Path.GetDirectoryName(file)); try { rpf.ScanStructure(null, null); var fileTypes = new List <string>() { ".ybn", ".ymap" }; RPFFunctions.SearchRPF(rpf, file, CurrentList, fileTypes); } catch (Exception) { MessageBox.Show("Error can't read " + file + ".\nThis file has been skipped.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } StringFunctions.SetCount(CurrentList, FilesAddedLabel, startButton); watch.Dispose(); }).Start(); }
public static void Create(string Type, string dlcName, string savePath) { try { Directory.CreateDirectory(savePath); var dlcRpf = RpfFile.CreateNew(savePath, "dlc.rpf", RpfEncryption.OPEN); var x64folder = RpfFile.CreateDirectory(dlcRpf.Root, "x64"); //create metas RpfFile.CreateFile(dlcRpf.Root, "content.xml", CreateContent(Type, dlcName)); RpfFile.CreateFile(dlcRpf.Root, "setup2.xml", CreateSetup(Type, dlcName)); //Dlc Map Pack if (Type == "Map") { var levelsFolder = RpfFile.CreateDirectory(x64folder, "levels"); var gta5Fodler = RpfFile.CreateDirectory(levelsFolder, "gta5"); var dlcChildRpf = RpfFile.CreateNew(gta5Fodler, dlcName + ".rpf", RpfEncryption.OPEN); var dlcMetaChildRpf = RpfFile.CreateNew(gta5Fodler, dlcName + "_metadata.rpf", RpfEncryption.OPEN); } if (Type == "Vehicle") { } MessageBox.Show("Successfully created dlc pack at: " + savePath); } catch { MessageBox.Show("Error dlc pack already exist at: " + savePath); } }
private void startButton_Click(object sender, EventArgs e) { timerTime = DateTime.Now; watch = new System.Threading.Timer(Tick, null, 0, 10); cancelButton.Enabled = true; var errorFiles = new List <string>() { }; new Thread(() => { Thread.CurrentThread.IsBackground = true; //while (cancelLoop) //{ for (var j = 0; j < CurrentList.Items.Count; j++) { string filename = CurrentList.Items[j].ToString(); FilesAddedLabel.Text = "Processing " + Path.GetFileName(filename) + " (" + (j + 1) + " of " + CurrentList.Items.Count + ")"; Vector3 moveVec = new Vector3(float.Parse(xMove.Text), float.Parse(yMove.Text), float.Parse(zMove.Text)); //Quaternion rotVec = Quaternion.RotationYawPitchRoll(float.Parse(xRotate.Text), float.Parse(yRotate.Text), float.Parse(zRotate.Text)); if (backupFilesToolStripMenuItem.Checked) { if (!filename.Contains(".rpf")) { File.Copy(filename, $"{filename}.old", true); } else { string fileDirectory = StringFunctions.TopMostRPF(filename); File.Copy(fileDirectory, Path.Combine(fileDirectory, ".old")); } } if (filename.EndsWith(".ybn")) { YbnFile ybn = new YbnFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { ybn.Load(oldData); if (ybn.Bounds != null) { ybn.Bounds.BoxCenter += moveVec; ybn.Bounds.BoxMax += moveVec; ybn.Bounds.BoxMin += moveVec; ybn.Bounds.SphereCenter += moveVec; BoundComposite boundcomp = ybn.Bounds as BoundComposite; var compchilds = boundcomp?.Children?.data_items; if (boundcomp.BVH != null) { Vector3 boundcompBBC = MathFunctions.ConvertToVec3(boundcomp.BVH.BoundingBoxCenter); Vector3 boundcompBBMax = MathFunctions.ConvertToVec3(boundcomp.BVH.BoundingBoxMax); Vector3 boundcompBBMin = MathFunctions.ConvertToVec3(boundcomp.BVH.BoundingBoxMin); boundcomp.BVH.BoundingBoxCenter = new Vector4(boundcompBBC + moveVec, boundcomp.BVH.BoundingBoxCenter.W); boundcomp.BVH.BoundingBoxMax = new Vector4(boundcompBBMax + moveVec, boundcomp.BVH.BoundingBoxMax.W); boundcomp.BVH.BoundingBoxMin = new Vector4(boundcompBBMin + moveVec, boundcomp.BVH.BoundingBoxMin.W); } if (compchilds != null) { for (int i = 0; i < compchilds.Length; i++) { compchilds[i].BoxCenter += moveVec; compchilds[i].BoxMax += moveVec; compchilds[i].BoxMin += moveVec; compchilds[i].SphereCenter += moveVec; BoundBVH bgeom = compchilds[i] as BoundBVH; if (bgeom != null) { if (bgeom.BVH != null) { Vector3 bgeomBBC = MathFunctions.ConvertToVec3(bgeom.BVH.BoundingBoxCenter); Vector3 bgeomBBMax = MathFunctions.ConvertToVec3(bgeom.BVH.BoundingBoxMax); Vector3 bgeomBBMin = MathFunctions.ConvertToVec3(bgeom.BVH.BoundingBoxMin); bgeom.BVH.BoundingBoxCenter = new Vector4(bgeomBBC + moveVec, bgeom.BVH.BoundingBoxCenter.W); bgeom.BVH.BoundingBoxMax = new Vector4(bgeomBBMax + moveVec, bgeom.BVH.BoundingBoxMax.W); bgeom.BVH.BoundingBoxMin = new Vector4(bgeomBBMin + moveVec, bgeom.BVH.BoundingBoxMin.W); } bgeom.CenterGeom = bgeom.CenterGeom + moveVec; } } } } byte[] newData = ybn.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } } catch (Exception) { errorFiles.Add(filename); } } else if (filename.EndsWith(".ymap")) { YmapFile ymap = new YmapFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { ymap.Load(oldData); if (ymap.CarGenerators != null) { foreach (YmapCarGen yEnts in ymap.CarGenerators) { yEnts.SetPosition(yEnts.Position + moveVec); //yEnts.Orientation = Quaternion.Add(yEnts.Orientation, rotVec); } } if (ymap.AllEntities != null) { foreach (YmapEntityDef yEnts in ymap.AllEntities) { yEnts.SetPosition(yEnts.Position + moveVec); //yEnts.Orientation = Quaternion.Add(yEnts.Orientation, rotVec); } } if (ymap.DistantLODLights != null) { int lightCount = ymap._CMapData.DistantLODLightsSOA.position.Count1; for (int i = 0; i < lightCount; i++) { Vector3 vector3 = ymap.DistantLODLights.positions[i].ToVector3() + moveVec; MetaVECTOR3 metaVec = new MetaVECTOR3 { x = vector3.X, y = vector3.Y, z = vector3.Z }; ymap.DistantLODLights.positions[i] = metaVec; } } if (ymap.GrassInstanceBatches != null) { foreach (YmapGrassInstanceBatch yEnts in ymap.GrassInstanceBatches) { yEnts.Position += moveVec; yEnts.AABBMin += moveVec; yEnts.AABBMax += moveVec; } } ymap._CMapData.streamingExtentsMax = ymap.CMapData.streamingExtentsMax + moveVec; ymap._CMapData.streamingExtentsMin = ymap.CMapData.streamingExtentsMin + moveVec; ymap._CMapData.entitiesExtentsMax = ymap.CMapData.entitiesExtentsMax + moveVec; ymap._CMapData.entitiesExtentsMin = ymap.CMapData.entitiesExtentsMin + moveVec; byte[] newData = ymap.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } } catch (Exception) { errorFiles.Add(filename); } } } if (errorFiles.Count != 0) { string message = "The following file(s) were corrupted and were not edited.\n\n"; foreach (string item in errorFiles) { message = message + item + "\n"; } MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } FilesAddedLabel.Text = "Complete"; cancelButton.Enabled = false; watch.Dispose(); //} }).Start(); }
private bool SaveToRPF(string txt) { if (!(exploreForm?.EditMode ?? false)) { return(false); } if (rpfFileEntry?.Parent == null) { return(false); } byte[] data = null; if (fileType == TextFileType.Text) { data = Encoding.UTF8.GetBytes(txt); } else if (fileType == TextFileType.GXT2) { var gxt = Gxt2File.FromText(txt); data = gxt.Save(); } else if (fileType == TextFileType.Nametable) { if (!txt.EndsWith("\n")) { txt = txt + "\n"; } txt = txt.Replace("\r", ""); var lines = txt.Split('\n'); foreach (var line in lines) { var str = line.Trim(); if (string.IsNullOrEmpty(str)) { continue; } var strl = str.ToLowerInvariant(); JenkIndex.Ensure(strl); } data = Encoding.UTF8.GetBytes(txt.Replace('\n', '\0')); } if (data == null) { MessageBox.Show("Unspecified error - data was null!", "Cannot save file"); return(false); } if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) { if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false);//that was a close one } } try { if (!(exploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) { return(false); } var newentry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); if (newentry != rpfFileEntry) { } rpfFileEntry = newentry; exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... modified = false; StatusLabel.Text = fileType.ToString() + " file saved successfully at " + DateTime.Now.ToString(); return(true); //victory! } catch (Exception ex) { MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error"); } return(false); }
private TreeNode AddFileNode(RpfFile file, TreeNode n) { var nodes = (n == null) ? MainTreeView.Nodes : n.Nodes; TreeNode node = nodes.Add(file.Path); node.Tag = file; foreach (RpfEntry entry in file.AllEntries) { if (entry is RpfFileEntry) { bool show = !entry.NameLower.EndsWith(".rpf"); //rpf entries get their own root node.. if (show) { //string text = entry.Path.Substring(file.Path.Length + 1); //includes \ on the end //TreeNode cnode = node.Nodes.Add(text); //cnode.Tag = entry; TreeNode cnode = AddEntryNode(entry, node); } } } //make sure it's all in jenkindex... JenkIndex.Ensure(file.Name); foreach (RpfEntry entry in file.AllEntries) { if (string.IsNullOrEmpty(entry.Name)) { continue; } JenkIndex.Ensure(entry.Name); JenkIndex.Ensure(entry.NameLower); int ind = entry.Name.LastIndexOf('.'); if (ind > 0) { JenkIndex.Ensure(entry.Name.Substring(0, ind)); JenkIndex.Ensure(entry.NameLower.Substring(0, ind)); } } return(node); //TreeNode lastNode = null; //string subPathAgg; //subPathAgg = string.Empty; //foreach (string subPath in file.Path.Split('\\')) //{ // subPathAgg += subPath + '\\'; // TreeNode[] nodes = MainTreeView.Nodes.Find(subPathAgg, true); // if (nodes.Length == 0) // { // if (lastNode == null) // { // lastNode = MainTreeView.Nodes.Add(subPathAgg, subPath); // } // else // { // lastNode = lastNode.Nodes.Add(subPathAgg, subPath); // } // } // else // { // lastNode = nodes[0]; // } //} //lastNode.Tag = file; }
private void ScanButton_Click(object sender, EventArgs e) { if (InProgress) { return; } if (!KeysLoaded) //this shouldn't ever really happen anymore { MessageBox.Show("Please scan a GTA 5 exe dump for keys first, or include key files in this app's folder!"); return; } if (!Directory.Exists(FolderTextBox.Text)) { MessageBox.Show("Folder doesn't exist: " + FolderTextBox.Text); return; } InProgress = true; AbortOperation = false; ScannedFiles.Clear(); RootFiles.Clear(); MainTreeView.Nodes.Clear(); string searchpath = FolderTextBox.Text; string replpath = searchpath + "\\"; Task.Run(() => { UpdateStatus("Starting scan..."); string[] allfiles = Directory.GetFiles(searchpath, "*.rpf", SearchOption.AllDirectories); uint totrpfs = 0; uint totfiles = 0; uint totfolders = 0; uint totresfiles = 0; uint totbinfiles = 0; foreach (string rpfpath in allfiles) { if (AbortOperation) { UpdateStatus("Scan aborted!"); InProgress = false; return; } RpfFile rf = new RpfFile(rpfpath, rpfpath.Replace(replpath, "")); UpdateStatus("Scanning " + rf.Name + "..."); rf.ScanStructure(UpdateStatus, UpdateStatus); totrpfs += rf.GrandTotalRpfCount; totfiles += rf.GrandTotalFileCount; totfolders += rf.GrandTotalFolderCount; totresfiles += rf.GrandTotalResourceCount; totbinfiles += rf.GrandTotalBinaryFileCount; AddScannedFile(rf, null, true); RootFiles.Add(rf); } UpdateStatus(string.Format("Scan complete. {0} RPF files, {1} total files, {2} total folders, {3} resources, {4} binary files.", totrpfs, totfiles, totfolders, totresfiles, totbinfiles)); InProgress = false; TotalFileCount = (int)totfiles; }); }
private void AddRpfFile(RpfFile file, bool isdlc, bool ismod) { isdlc = isdlc || (file.NameLower == "dlc.rpf") || (file.NameLower == "update.rpf"); ismod = ismod || (file.Path.StartsWith("mods\\")); if (file.AllEntries != null) { AllRpfs.Add(file); if (!ismod) { AllNoModRpfs.Add(file); } if (isdlc) { DlcRpfs.Add(file); if (!ismod) { DlcNoModRpfs.Add(file); } } else { if (ismod) { ModRpfs.Add(file); } else { BaseRpfs.Add(file); } } if (ismod) { ModRpfDict[file.Path.Substring(5)] = file; } RpfDict[file.Path] = file; foreach (RpfEntry entry in file.AllEntries) { try { if (!string.IsNullOrEmpty(entry.Name)) { if (ismod) { ModEntryDict[entry.Path] = entry; ModEntryDict[entry.Path.Substring(5)] = entry; } else { EntryDict[entry.Path] = entry; } if (entry is RpfFileEntry) { RpfFileEntry fentry = entry as RpfFileEntry; entry.NameHash = JenkHash.GenHash(entry.NameLower); int ind = entry.NameLower.LastIndexOf('.'); entry.ShortNameHash = (ind > 0) ? JenkHash.GenHash(entry.NameLower.Substring(0, ind)) : entry.NameHash; if (entry.ShortNameHash != 0) { //EntryHashDict[entry.ShortNameHash] = entry; } } } } catch (Exception ex) { file.LastError = ex.ToString(); file.LastException = ex; ErrorLog(entry.Path + ": " + ex.ToString()); } } } if (file.Children != null) { foreach (RpfFile cfile in file.Children) { AddRpfFile(cfile, isdlc, ismod); } } }
private bool SaveRel(XmlDocument doc) { if (!(exploreForm?.EditMode ?? false)) { return(false); } if (rpfFileEntry?.Parent == null) { return(false); } byte[] data = null; #if !DEBUG try #endif { switch (metaFormat) { default: case MetaFormat.XML: return(false); //what are we even doing here? case MetaFormat.AudioRel: var rel = XmlRel.GetRel(doc); if ((rel?.RelDatasSorted == null) || (rel.RelDatasSorted.Length == 0)) { MessageBox.Show("Schema not supported.", "Cannot import REL XML"); return(false); } data = rel.Save(); break; } } #if !DEBUG catch (Exception ex) { MessageBox.Show("Exception encountered!\r\n" + ex.ToString(), "Cannot convert XML"); return(false); } #endif if (data == null) { MessageBox.Show("Schema not supported. (Unspecified error - data was null!)", "Cannot convert XML"); return(false); } if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) { if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false);//that was a close one } } try { if (!(exploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) { return(false); } var newentry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); if (newentry != rpfFileEntry) { } rpfFileEntry = newentry; exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... modified = false; StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString(); return(true); //victory! } catch (Exception ex) { MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error"); } return(false); }
static void ExtractFilesInRPF(RpfFile rpf, string directoryOffset) { try { using (BinaryReader br = new BinaryReader(File.OpenRead(rpf.GetPhysicalFilePath()))) { foreach (RpfEntry entry in rpf.AllEntries) { if (!entry.NameLower.EndsWith(".rpf")) //don't try to extract rpf's, they will be done separately.. { if (entry is RpfBinaryFileEntry) { RpfBinaryFileEntry binentry = entry as RpfBinaryFileEntry; byte[] data = rpf.ExtractFileBinary(binentry, br); if (data == null) { if (binentry.FileSize == 0) { Console.WriteLine("Invalid binary file size!"); } else { Console.WriteLine("data is null!"); } } else if (data.Length == 0) { Console.WriteLine("{0} : Decompressed output was empty.", entry.Path); } else { Console.WriteLine("binary meme -> " + entry.NameLower); File.WriteAllBytes(directoryOffset + entry.NameLower, data); } } else if (entry is RpfResourceFileEntry) { RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; byte[] data = rpf.ExtractFileResource(resentry, br); data = ResourceBuilder.Compress(data); //not completely ideal to recompress it... data = ResourceBuilder.AddResourceHeader(resentry, data); if (data == null) { if (resentry.FileSize == 0) { Console.WriteLine("{0} : Resource FileSize is 0.", entry.Path); } else { Console.WriteLine("{0} : {1}", entry.Path); } } else if (data.Length == 0) { Console.WriteLine("{0} : Decompressed output was empty.", entry.Path); } else { Console.WriteLine("Potential meme -> " + entry.NameLower); foreach (KeyValuePair <string, string[]> extentionMap in extensions) { foreach (string extention in extentionMap.Value) { if (entry.NameLower.EndsWith(extention)) { Console.WriteLine("Resource meme -> " + entry.NameLower); if (extention.Equals(".ytd")) { RpfFileEntry rpfent = entry as RpfFileEntry; byte[] ytddata = rpfent.File.ExtractFile(rpfent); bool needsResized = ytddata.Length > 5242880; // 5MB YtdFile ytd = new YtdFile(); ytd.Load(ytddata, rpfent); Dictionary <uint, Texture> Dicts = new Dictionary <uint, Texture>(); bool somethingResized = false; foreach (KeyValuePair <uint, Texture> texture in ytd.TextureDict.Dict) { if (texture.Value.Width > 1440 || needsResized && texture.Value.Width > 550) // Only resize if it is greater than 1440p or 550p if vehicle is oversized { byte[] dds = DDSIO.GetDDSFile(texture.Value); string fileName = $"{texture.Value.Name}.dds"; fileName = String.Concat(fileName.Where(c => !Char.IsWhiteSpace(c))); File.WriteAllBytes("./NConvert/" + fileName, dds); Process p = new Process(); p.StartInfo.FileName = @"./NConvert/nconvert.exe"; p.StartInfo.Arguments = @"-out dds -resize 50% 50% -overwrite ./NConvert/" + fileName; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.Start(); //Wait for the process to end. p.WaitForExit(); // Move file back File.Move("./NConvert/" + fileName, directoryOffset + fileName); byte[] resizedData = File.ReadAllBytes(directoryOffset + fileName); Texture resizedTex = DDSIO.GetTexture(resizedData); resizedTex.Name = texture.Value.Name; Console.WriteLine(resizedData.Length.ToString()); Dicts.Add(texture.Key, resizedTex); // Yeet the file, we are done with it File.Delete(directoryOffset + fileName); somethingResized = true; } else { Dicts.Add(texture.Key, texture.Value); } } // No point rebuilding the ytd when nothing was resized if (!somethingResized) { break; } TextureDictionary dic = new TextureDictionary(); dic.Textures = new ResourcePointerList64 <Texture>(); dic.TextureNameHashes = new ResourceSimpleList64_uint(); dic.Textures.data_items = Dicts.Values.ToArray(); dic.TextureNameHashes.data_items = Dicts.Keys.ToArray(); dic.BuildDict(); ytd.TextureDict = dic; byte[] resizedYtdData = ytd.Save(); File.WriteAllBytes(directoryOffset + entry.NameLower, resizedYtdData); Console.WriteLine("Done some ytd resize memes -> " + entry.NameLower); break; } File.WriteAllBytes(directoryOffset + entry.NameLower, data); break; } } } if (entry.NameLower.EndsWith(".ytd")) { latestModelName = entry.NameLower.Remove(entry.NameLower.Length - 4); } } } } else { // Write file first RpfBinaryFileEntry binentry = entry as RpfBinaryFileEntry; byte[] data = rpf.ExtractFileBinary(binentry, br); File.WriteAllBytes(directoryOffset + entry.NameLower, data); RpfFile subRPF = new RpfFile(directoryOffset + entry.NameLower, directoryOffset + entry.NameLower); if (subRPF.ScanStructure(null, null)) { //recursive memes ExtractFilesInRPF(subRPF, directoryOffset); } //yeet File.Delete(directoryOffset + entry.NameLower); } } } } catch (Exception e) { Console.WriteLine("Exception memes!"); Console.WriteLine(e.Message); } }
private void SaveYTD(bool saveas = false) { if (Ytd == null) { return; } if (!(ExploreForm?.EditMode ?? false)) { saveas = true; } var isinrpf = false; var rpfFileEntry = Ytd.RpfFileEntry; if (rpfFileEntry == null) { saveas = true; } else { if (rpfFileEntry?.Parent != null) { if (!saveas) { isinrpf = true; if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) { if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) { saveas = true;//that was a close one isinrpf = false; } } } } else if (!string.IsNullOrEmpty(rpfFileEntry?.Path)) { isinrpf = false; //saving direct to filesystem in RPF explorer... } else { saveas = true;//this probably shouldn't happen } } var data = Ytd.Save(); if (saveas) //save direct to filesystem in external location { SaveYTDFileDialog.FileName = FileName; if (SaveYTDFileDialog.ShowDialog() != DialogResult.OK) { return; } string fpath = SaveYTDFileDialog.FileName; File.WriteAllBytes(fpath, data); } else if (!isinrpf) //save direct to filesystem in RPF explorer { File.WriteAllBytes(rpfFileEntry.Path, data); ExploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... } else //save to RPF... { if (!(ExploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) { MessageBox.Show("Unable to save file, RPF encryption needs to be OPEN for this operation!"); return; } Ytd.RpfFileEntry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); ExploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... } Modified = false; UpdateStatus("YTD file saved successfully at " + DateTime.Now.ToString()); UpdateFormTitle(); }
private void startButton_Click(object sender, EventArgs e) { var watch = Stopwatch.StartNew(); TimeLabel.Text = "Time Elapsed: 0ms"; cancelButton.Enabled = true; var errorFiles = new List <string>() { }; new Thread(() => { Thread.CurrentThread.IsBackground = true; for (var j = 0; j < CurrentList.Items.Count; j++) { if (CancelLoop) { FilesAddedLabel.Text = "Cancelled"; CancelLoop = false; return; } string filename = CurrentList.Items[j].ToString(); FilesAddedLabel.Text = "Processing " + Path.GetFileName(filename) + " (" + (j + 1) + " of " + CurrentList.Items.Count + ")"; if (filename.EndsWith(".ybn")) { YbnFile ybn = new YbnFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { ybn.Load(oldData); byte[] newData = ybn.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } catch (Exception) { errorFiles.Add(filename); } } else if (filename.EndsWith(".ydr")) { YdrFile ydr = new YdrFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { RpfFile.LoadResourceFile(ydr, oldData, 165); byte[] newData = ydr.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } catch (Exception) { errorFiles.Add(filename); } } else if (filename.EndsWith(".ydd")) { YddFile ydd = new YddFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { RpfFile.LoadResourceFile(ydd, oldData, 165); byte[] newData = ydd.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } catch (Exception) { errorFiles.Add(filename); } } else if (filename.EndsWith(".yft")) { YftFile yft = new YftFile(); RpfDirectoryEntry RPFFilesDirectory; byte[] oldData; if (filename.Contains(".rpf")) { string fileDirectory = StringFunctions.TopMostRPF(filename); if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RpfFile TopRPF = new RpfFile(fileDirectory, fileDirectory); TopRPF.ScanStructure(null, null); (RPFFilesDirectory, oldData) = RPFFunctions.GetFileData(TopRPF, Path.GetFileName(filename)); } } else { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } try { RpfFile.LoadResourceFile(yft, oldData, 162); byte[] newData = yft.Save(); if (filename.Contains(".rpf")) { if (File.Exists(filename)) { RPFFilesDirectory = null; oldData = File.ReadAllBytes(filename); } else { RPFFunctions.AddFileBackToRPF(RPFFilesDirectory, filename, newData); } } else { File.WriteAllBytes(filename, newData); } var elapsedMss = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMss).ToString(); } catch (Exception) { errorFiles.Add(filename); } } } if (errorFiles.Count != 0) { string message = "The following file(s) were corrupted and were not edited.\n\n"; foreach (string item in errorFiles) { message = message + item + "\n"; } MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } FilesAddedLabel.Text = "Complete"; var elapsedMs = watch.ElapsedMilliseconds; TimeLabel.Text = "Time Elapsed: " + StringFunctions.ConvertMillisecondsToSeconds(elapsedMs).ToString(); cancelButton.Enabled = false; }).Start(); }
public bool SaveMeta(XmlDocument doc) { //if explorer is in edit mode, and the current RpfFileEntry is valid, convert XML to the //current meta format and then save the file into the RPF. //otherwise, save the generated file to disk? //(currently just return false and revert to XML file save) if (!(exploreForm?.EditMode ?? false)) { return(false); } if (rpfFileEntry?.Parent == null) { return(false); } byte[] data = null; #if !DEBUG try #endif { switch (metaFormat) { default: case MetaFormat.XML: return(false); //what are we even doing here? case MetaFormat.RSC: var meta = XmlMeta.GetMeta(doc); if ((meta.DataBlocks?.Data == null) || (meta.DataBlocks.Count == 0)) { MessageBox.Show("Schema not supported.", "Cannot import Meta XML"); return(false); } data = ResourceBuilder.Build(meta, 2); //meta is RSC "Version":2 (it's actually a type identifier, not a version!) break; case MetaFormat.PSO: var pso = XmlPso.GetPso(doc); if ((pso.DataSection == null) || (pso.DataMapSection == null) || (pso.SchemaSection == null)) { MessageBox.Show("Schema not supported.", "Cannot import PSO XML"); return(false); } data = pso.Save(); break; case MetaFormat.RBF: var rbf = XmlRbf.GetRbf(doc); if (rbf.current == null) { MessageBox.Show("Schema not supported.", "Cannot import RBF XML"); return(false); } data = rbf.Save(); break; case MetaFormat.Ynd: var ynd = XmlYnd.GetYnd(doc); if (ynd.NodeDictionary == null) { MessageBox.Show("Schema not supported.", "Cannot import YND XML"); return(false); } data = ynd.Save(); break; case MetaFormat.CacheFile: MessageBox.Show("Sorry, CacheFile import is not supported.", "Cannot import CacheFile XML"); return(false); } } #if !DEBUG catch (Exception ex) { MessageBox.Show("Exception encountered!\r\n" + ex.ToString(), "Cannot convert XML"); return(false); } #endif if (data == null) { MessageBox.Show("Schema not supported. (Unspecified error - data was null!)", "Cannot convert XML"); return(false); } if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) { if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) { return(false);//that was a close one } } try { if (!(exploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) { return(false); } var newentry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); if (newentry != rpfFileEntry) { } rpfFileEntry = newentry; exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... modified = false; StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString(); return(true); //victory! } catch (Exception ex) { MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error"); } return(false); }
// TODO: support for loading NG encrypted data public void Load(byte[] data) => RpfFile.LoadResourceFile(this, data, FileVersion);