Exemplo n.º 1
0
        public bool MovePrevious()
        {
            AllocationTableEntry currentEntry = Fat.Entries[PhysicalBlock + 1];

            if (currentEntry.IsListStart())
            {
                return(false);
            }
            int newBlock = currentEntry.Prev & 0x7FFFFFFF;

            AllocationTableEntry newEntry = Fat.Entries[newBlock];

            if (newEntry.IsSingleBlockSegment())
            {
                CurrentSegmentSize = 1;
            }
            else
            {
                AllocationTableEntry lengthEntry = Fat.Entries[newBlock + 1];
                CurrentSegmentSize = lengthEntry.Next - (newBlock - 1);
            }

            VirtualBlock -= CurrentSegmentSize;
            PhysicalBlock = newBlock - 1;
            return(true);
        }
Exemplo n.º 2
0
        public bool BeginIteration(int initialBlock)
        {
            AllocationTableEntry tableEntry = Fat.Entries[initialBlock + 1];

            if (!tableEntry.IsListStart())
            {
                return(false);
            }

            if (tableEntry.IsSingleBlockSegment())
            {
                CurrentSegmentSize = 1;
            }
            else
            {
                AllocationTableEntry lengthEntry = Fat.Entries[initialBlock + 2];
                CurrentSegmentSize = lengthEntry.Next - initialBlock;
            }

            PhysicalBlock = initialBlock;

            return(true);
        }
Exemplo n.º 3
0
        public void Free(int listBlockIndex)
        {
            int listEntryIndex             = BlockToEntryIndex(listBlockIndex);
            AllocationTableEntry listEntry = ReadEntry(listEntryIndex);

            if (!listEntry.IsListStart())
            {
                throw new ArgumentOutOfRangeException(nameof(listBlockIndex), "The block to free must be the start of a list.");
            }

            int freeListIndex = GetFreeListEntryIndex();

            // Free list is empty
            if (freeListIndex == 0)
            {
                SetFreeListEntryIndex(listEntryIndex);
                return;
            }

            Join(listBlockIndex, EntryIndexToBlock(freeListIndex));

            SetFreeListBlockIndex(listBlockIndex);
        }