private void LoadDirectory(Toc toc, int index) { listView.Items.Clear(); rpf::Directory myDir = toc.FileSystemEntriesList[index] as rpf::Directory; for (int i = myDir.FirstOffset; i < myDir.FirstOffset + myDir.Count; i++) { //try this one after the roll-out of the next gui preview listView.Items.Add(i.ToString(), toc.FileSystemEntriesList[i].Name, 0); if (toc.FileSystemEntriesList[i].GetType() == typeof(rpf::Directory)) { rpf::Directory crtDirectory = toc.FileSystemEntriesList[i] as rpf::Directory; listView.Items[i.ToString()].SubItems.Add("Folder"); listView.Items[i.ToString()].SubItems.Add(crtDirectory.Count + " items"); listView.Items[i.ToString()].SubItems.Add("Folder"); listView.Items[i.ToString()].SubItems.Add("No"); listView.Items[i.ToString()].Group = listView.Groups["dir"]; } else { rpf::File crtFile = toc.FileSystemEntriesList[i] as rpf::File; listView.Items[i.ToString()].SubItems.Add("File"); listView.Items[i.ToString()].SubItems.Add(rpf::Calculator.CalculateSize(crtFile.Size)); listView.Items[i.ToString()].SubItems.Add("No"); listView.Items[i.ToString()].SubItems.Add("No"); } } }
private void MainForm_Shown(object sender, EventArgs e) { if (rpfPath == "") { OpenFileDialog ofd = new OpenFileDialog(); ofd.AddExtension = true; ofd.Filter = "RPF0 files (*.rpf)|*.rpf"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.DefaultExt = ".rpf"; ofd.ShowDialog(); rpfPath = ofd.FileName; } MainForm.ActiveForm.BringToFront(); FileStream rpfStream = File.Open(rpfPath, FileMode.Open); byte[] temp = new byte[20]; rpfStream.Read(temp, 0, 20); rpfStream.Close(); Header header = new Header(new MemoryStream(temp)); rpfStream = File.Open(rpfPath, FileMode.Open); temp = new byte[header.GetTocSize()]; rpfStream.Seek(2048, SeekOrigin.Begin); rpfStream.Read(temp, 0, header.GetTocSize()); rpfStream.Close(); toc = new Toc(new MemoryStream(temp), header.GetCount()); if (toc.FileSystemEntriesList[0].GetType() == typeof(rpf::Directory)) { LoadDirectory(toc, 0); } else { MessageBox.Show("RPF must start with a root directory."); } }