コード例 #1
0
        public override int Parse(byte[] buffer, int offset)
        {
            VolumeDescriptorSequenceNumber = Utilities.ToUInt32LittleEndian(buffer, offset + 16);
            DescriptorCharset        = Utilities.ToByteArray(buffer, offset + 20, 64);
            LogicalVolumeIdentifier  = UdfUtilities.ReadDString(buffer, offset + 84, 128);
            LogicalBlockSize         = Utilities.ToUInt32LittleEndian(buffer, offset + 212);
            DomainIdentifier         = Utilities.ToStruct <DomainEntityIdentifier>(buffer, offset + 216);
            LogicalVolumeContentsUse = Utilities.ToByteArray(buffer, offset + 248, 16);
            MapTableLength           = Utilities.ToUInt32LittleEndian(buffer, offset + 264);
            NumPartitionMaps         = Utilities.ToUInt32LittleEndian(buffer, offset + 268);
            ImplementationIdentifier = Utilities.ToStruct <ImplementationEntityIdentifier>(buffer, offset + 272);
            ImplementationUse        = Utilities.ToByteArray(buffer, offset + 304, 128);
            IntegritySequenceExtent  = new ExtentDescriptor();
            IntegritySequenceExtent.ReadFrom(buffer, offset + 432);

            int pmOffset = 0;

            PartitionMaps = new PartitionMap[NumPartitionMaps];
            for (int i = 0; i < NumPartitionMaps; ++i)
            {
                PartitionMaps[i] = PartitionMap.CreateFrom(buffer, offset + 440 + pmOffset);
                pmOffset        += PartitionMaps[i].Size;
            }

            return(440 + (int)MapTableLength);
        }
コード例 #2
0
        public static LogicalPartition FromDescriptor(UdfContext context, LogicalVolumeDescriptor volumeDescriptor, int index)
        {
            PartitionMap map = volumeDescriptor.PartitionMaps[index];

            Type1PartitionMap asType1 = map as Type1PartitionMap;

            if (asType1 != null)
            {
                return(new Type1Partition(context, volumeDescriptor, asType1));
            }

            MetadataPartitionMap asMetadata = map as MetadataPartitionMap;

            if (asMetadata != null)
            {
                return(new MetadataPartition(context, volumeDescriptor, asMetadata));
            }

            throw new NotImplementedException("Unrecognized partition map type");
        }
コード例 #3
0
        public static PartitionMap CreateFrom(byte[] buffer, int offset)
        {
            PartitionMap result = null;

            byte type = buffer[offset];

            if (type == 1)
            {
                result = new Type1PartitionMap();
            }
            else if (type == 2)
            {
                EntityIdentifier id = Utilities.ToStruct <UdfEntityIdentifier>(buffer, offset + 4);
                switch (id.Identifier)
                {
                case "*UDF Virtual Partition":
                    result = new VirtualPartitionMap();
                    break;

                case "*UDF Sparable Partition":
                    result = new SparablePartitionMap();
                    break;

                case "*UDF Metadata Partition":
                    result = new MetadataPartitionMap();
                    break;

                default:
                    throw new InvalidDataException("Unrecognized partition map entity id: " + id);
                }
            }

            if (result != null)
            {
                result.ReadFrom(buffer, offset);
            }

            return(result);
        }