示例#1
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);
        }
示例#2
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);
            }
        }