예제 #1
0
        private void ReadShortDescriptors(byte[] activeBuffer)
        {
            long filePos = 0;

            int i = 0;

            while (i < activeBuffer.Length)
            {
                ShortAllocationDescriptor sad = Utilities.ToStruct <ShortAllocationDescriptor>(activeBuffer, i);
                if (sad.ExtentLength == 0)
                {
                    break;
                }

                if (sad.Flags != ShortAllocationFlags.RecordedAndAllocated)
                {
                    throw new NotImplementedException("Extents that are not 'recorded and allocated' not implemented");
                }

                CookedExtent newExtent = new CookedExtent
                {
                    FileContentOffset = filePos,
                    Partition         = int.MaxValue,
                    StartPos          = sad.ExtentLocation * (long)_blockSize,
                    Length            = sad.ExtentLength
                };
                _extents.Add(newExtent);

                filePos += sad.ExtentLength;
                i       += sad.Size;
            }
        }
예제 #2
0
        private void LoadExtents()
        {
            _extents = new List <CookedExtent>();
            byte[] activeBuffer = _fileEntry.AllocationDescriptors;

            AllocationType allocType = _fileEntry.InformationControlBlock.AllocationType;

            if (allocType == AllocationType.ShortDescriptors)
            {
                long filePos = 0;

                int i = 0;
                while (i < activeBuffer.Length)
                {
                    ShortAllocationDescriptor sad = EndianUtilities.ToStruct <ShortAllocationDescriptor>(activeBuffer, i);
                    if (sad.ExtentLength == 0)
                    {
                        break;
                    }

                    if (sad.Flags != ShortAllocationFlags.RecordedAndAllocated)
                    {
                        throw new NotImplementedException(
                                  "Extents that are not 'recorded and allocated' not implemented");
                    }

                    CookedExtent newExtent = new CookedExtent
                    {
                        FileContentOffset = filePos,
                        Partition         = int.MaxValue,
                        StartPos          = sad.ExtentLocation * (long)_blockSize,
                        Length            = sad.ExtentLength
                    };
                    _extents.Add(newExtent);

                    filePos += sad.ExtentLength;
                    i       += sad.Size;
                }
            }
            else if (allocType == AllocationType.Embedded)
            {
                // do nothing
            }
            else if (allocType == AllocationType.LongDescriptors)
            {
                long filePos = 0;

                int i = 0;
                while (i < activeBuffer.Length)
                {
                    LongAllocationDescriptor lad = EndianUtilities.ToStruct <LongAllocationDescriptor>(activeBuffer, i);
                    if (lad.ExtentLength == 0)
                    {
                        break;
                    }

                    CookedExtent newExtent = new CookedExtent
                    {
                        FileContentOffset = filePos,
                        Partition         = lad.ExtentLocation.Partition,
                        StartPos          = lad.ExtentLocation.LogicalBlock * (long)_blockSize,
                        Length            = lad.ExtentLength
                    };
                    _extents.Add(newExtent);

                    filePos += lad.ExtentLength;
                    i       += lad.Size;
                }
            }
            else
            {
                throw new NotImplementedException("Allocation Type: " +
                                                  _fileEntry.InformationControlBlock.AllocationType);
            }
        }