Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        private static void GenerateDirectoryTable(
            List <DirectoryTableEntry> directoryTable,
            FileSystem.Directory dir)
        {
            DirectoryTableEntry directoryTableEntry = new DirectoryTableEntry();

            if (dir.IsRoot)
            {
                directoryTableEntry.dirParentID   = (ushort)(dir.TotalNrSubDirectories + 1U);
                directoryTableEntry.dirEntryStart = (uint)directoryTableEntry.dirParentID * 8U;
            }
            else
            {
                directoryTableEntry.dirParentID = dir.Parent.DirectoryID;
            }
            dir.DirectoryID = (ushort)(61440 + directoryTable.Count);
            directoryTable.Add(directoryTableEntry);
            foreach (FileSystem.Directory subDirectory in dir.SubDirectories)
            {
                NARC_new.GenerateDirectoryTable(directoryTable, subDirectory);
            }
        }