示例#1
0
        public void LinkSectorID(int sectorID, int newSectorID)
        {
            if (sectorID < 0)
            {
                throw new ArgumentOutOfRangeException("sectorID");
            }
            int SATSectorIndex = sectorID / SecIDCapacity;
            int SectorIndex    = sectorID % SecIDCapacity;

            int SATSectorID = Document.MasterSectorAllocation.GetSATSectorID(SATSectorIndex);

            Document.WriteInSector(SATSectorID, SectorIndex * 4, newSectorID);
        }
示例#2
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);
        }
示例#3
0
 public void Save()
 {
     if (ShortSectorAllocationTable.Count > 0)
     {
         if (Document.Header.FirstSectorIDofShortSectorAllocationTable == SID.EOC)
         {
             int   SecIDCapacity = Document.SectorSize / 4;
             int[] sids          = new Int32[SecIDCapacity];
             for (int i = 0; i < sids.Length; i++)
             {
                 sids[i] = SID.Free;
             }
             Document.Header.FirstSectorIDofShortSectorAllocationTable = Document.AllocateDataSector();
             Document.WriteInSector(Document.Header.FirstSectorIDofShortSectorAllocationTable, 0, sids);
         }
         MemoryStream satStream = new MemoryStream(ShortSectorAllocationTable.Count * 4);
         CompoundDocument.WriteArrayOfInt32(new BinaryWriter(satStream), ShortSectorAllocationTable.ToArray());
         Document.WriteStreamData(Document.Header.FirstSectorIDofShortSectorAllocationTable, satStream.ToArray());
     }
 }