private static void GenerateEntryNameTable( List <DirectoryTableEntry> directoryTable, List <EntryNameTableEntry> entryNameTable, FileSystem.Directory dir, ref uint Offset, ref ushort FileId) { directoryTable[(int)dir.DirectoryID - 61440].dirEntryStart = Offset; directoryTable[(int)dir.DirectoryID - 61440].dirEntryFileID = FileId; foreach (FileSystem.Directory subDirectory in dir.SubDirectories) { entryNameTable.Add((EntryNameTableEntry) new EntryNameTableDirectoryEntry(subDirectory.DirectoryName, subDirectory.DirectoryID)); Offset += (uint)(subDirectory.DirectoryName.Length + 3); } foreach (FileSystem.File file in dir.Files) { file.FileID = (int)FileId; entryNameTable.Add((EntryNameTableEntry) new EntryNameTableFileEntry(file.FileName)); Offset += (uint)(file.FileName.Length + 1); ++FileId; } entryNameTable.Add((EntryNameTableEntry) new EntryNameTableEndOfDirectoryEntry()); ++Offset; foreach (FileSystem.Directory subDirectory in dir.SubDirectories) { NARC_new.GenerateEntryNameTable(directoryTable, entryNameTable, subDirectory, ref Offset, ref FileId); } }
public static NARC_new FromFileSystem(NARCFileSystem fileSystem) { NARC_new narcNew = new NARC_new(); narcNew.FATB.numFiles = (ushort)fileSystem.Root.TotalNrSubFiles; List <byte> byteList = new List <byte>(); for (ushort index = 0; (int)index < (int)narcNew.FATB.numFiles; ++index) { FileSystem.File fileById = fileSystem.Root.GetFileByID((int)index); narcNew.FATB.allocationTable.Add(new FileAllocationEntry((uint)byteList.Count, (uint)fileById.Data.Length)); byteList.AddRange((IEnumerable <byte>)fileById.Data); while (byteList.Count % 4 != 0) { byteList.Add(byte.MaxValue); } } narcNew.FIMG.fileImage = byteList.ToArray(); NARC_new.GenerateDirectoryTable(narcNew.FNTB.directoryTable, fileSystem.Root); uint dirEntryStart = narcNew.FNTB.directoryTable[0].dirEntryStart; ushort FileId = 0; NARC_new.GenerateEntryNameTable(narcNew.FNTB.directoryTable, narcNew.FNTB.entryNameTable, fileSystem.Root, ref dirEntryStart, ref FileId); return(narcNew); }