예제 #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);
        }
예제 #2
0
        public AllocationTable(Stream tableStream)
        {
            int blockCount = (int)(tableStream.Length / 8);

            Entries = new AllocationTableEntry[blockCount];
            tableStream.Position = 0;
            var reader = new BinaryReader(tableStream);

            for (int i = 0; i < blockCount; i++)
            {
                int parent = reader.ReadInt32();
                int child  = reader.ReadInt32();

                Entries[i] = new AllocationTableEntry {
                    Next = child, Prev = parent
                };
            }
        }
예제 #3
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);
        }