/** * This returns true if positively identified as LBA1 * This returns false if positively identified as LBA2 * Else returns null */ private Nullable <bool> parseBodyFile(string path) { int i; long fileSize; int offset = 0; Nullable <bool> lba1 = isLBA1File(new System.IO.FileInfo(path).Length); if (null != lba1) { lookup = new LookupLBABody(lba1); } FileStream fsStream = new FileStream(path, FileMode.Open, FileAccess.Read); LBA1 = false; //rbLBA1.Checked; //Clear the list view as it may have already //had a file loaded lvItemList.Clear(); //Reset column headers this.lvItemList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.chPosition, this.chOffset, this.chName }); fileSize = new System.IO.FileInfo(path).Length; for (i = 0; offset != fileSize; i++) { //Read in four bytes; int[] bytes = new int[4]; for (int j = 0; j < 4; j++) { bytes[j] = fsStream.ReadByte(); } //Reverse byte order offset = (bytes[3] << 24) + (bytes[2] << 16) + (bytes[1] << 8) + (bytes[0]); if (offset != fileSize) { //lookup.addOffset(offset); //Output OffSet location addLVItoLV(lvItemList, i + 1, offset, lookup.getName(offset + "")); } } lvItemList.Columns[0].Width = -1; lvItemList.Columns[1].Width = -1; lvItemList.Columns[2].Width = -1; NUMOFSKINS = i - 1; fsStream.Close(); return(isLBA1File(fileSize)); }
private void btnRestoreDefault_Click(object sender, EventArgs e) { int i; string str; if (0 >= lookup.getOffsetSize()) { lookup = new LookupLBABody(true); //ToDo Fix this shit Console.WriteLine("Size: " + lookup.getOffsetSize()); MessageBox.Show("Fix this!"); } for (i = 0; i < NUMOFSKINS; i++) { str = lookup.getOffset(i); Console.WriteLine(str); updateLVI(lvItemList, i, lookup.getOffset(i)); } }