Exemplo n.º 1
0
        public int AllocateSATSector()
        {
            int[] sids = new Int32[SecIDCapacity + 1];
            for (int i = 0; i < sids.Length; i++)
            {
                sids[i] = SID.Free;
            }
            int secID = Document.AllocateNewSector(sids);

            MasterSectorAllocationTable.Add(secID);
            NumberOfSecIDs++;
            int SATSectorIndex = NumberOfSecIDs - 1;

            if (NumberOfSecIDs <= 109)
            {
                Document.Header.MasterSectorAllocationTable[SATSectorIndex] = secID;
                Document.Write(76 + SATSectorIndex * 4, secID);
            }
            else
            {
                if (CurrentMSATSector == SID.EOC)
                {
                    CurrentMSATSector = AllocateMSATSector();
                    Document.Header.FirstSectorIDofMasterSectorAllocationTable = CurrentMSATSector;
                }
                int index = (SATSectorIndex - 109) % SecIDCapacity;
                Document.WriteInSector(CurrentMSATSector, index * 4, secID);
                if (index == SecIDCapacity - 1)
                {
                    int newMSATSector = AllocateMSATSector();
                    Document.WriteInSector(CurrentMSATSector, SecIDCapacity * 4, newMSATSector);
                    CurrentMSATSector = newMSATSector;
                }
            }
            Document.SectorAllocation.LinkSectorID(secID, SID.SAT);
            Document.Header.NumberOfSATSectors++;
            return(secID);
        }