public void FromFileSystem(SFSDirectory Root) { int did = 0; int fid = 0; Root.UpdateIDs(ref did, ref fid); //FileNameTable.numFiles = (ushort)Root.TotalNrSubFiles; //List<byte> Data = new List<byte>(); uint nrfiles = Root.TotalNrSubFiles; FileAllocationTable = new FileAllocationEntry[nrfiles]; //FATB.allocationTable.Clear(); for (ushort i = 0; i < nrfiles; i++) { var f = Root.GetFileByID(i); FileAllocationTable[i] = new FileAllocationEntry(0, 0); //FATB.allocationTable.Add(new FileAllocationEntry((uint)Data.Count, (uint)f.Data.Length)); //Data.AddRange(f.Data); //while ((Data.Count % 4) != 0) Data.Add(0xFF); } //FIMG.fileImage = Data.ToArray(); FileNameTable.DirectoryTable.Clear(); NitroFSUtil.GenerateDirectoryTable(FileNameTable.DirectoryTable, Root); uint offset2 = FileNameTable.DirectoryTable[0].dirEntryStart; ushort fileId = 0; FileNameTable.EntryNameTable.Clear(); NitroFSUtil.GenerateEntryNameTable(FileNameTable.DirectoryTable, FileNameTable.EntryNameTable, Root, ref offset2, ref fileId); }
public UtilityBin(byte[] Data) { EndianBinaryReader er = new EndianBinaryReader(new MemoryStream(Data), Endianness.LittleEndian); Header = new UtilityBinHeader(er); er.BaseStream.Position = Header.FileNameTableOffset; FileNameTable = new UtilityBinFNT(er); er.BaseStream.Position = Header.FileAllocationTableOffset; FileAllocationTable = new FileAllocationEntry[Header.FileAllocationTableSize / 8]; for (int i = 0; i < Header.FileAllocationTableSize / 8; i++) { FileAllocationTable[i] = new FileAllocationEntry(er); } FileData = new byte[Header.FileAllocationTableSize / 8][]; for (int i = 0; i < Header.FileAllocationTableSize / 8; i++) { er.BaseStream.Position = FileAllocationTable[i].fileTop; FileData[i] = er.ReadBytes((int)FileAllocationTable[i].fileSize); } er.Close(); }