示例#1
0
        public MetadataPartition(UdfContext context, LogicalVolumeDescriptor volumeDescriptor, MetadataPartitionMap partitionMap)
            : base(context, volumeDescriptor)
        {
            _partitionMap = partitionMap;

            PhysicalPartition physical = context.PhysicalPartitions[partitionMap.PartitionNumber];
            long fileEntryPos          = partitionMap.MetadataFileLocation * (long)volumeDescriptor.LogicalBlockSize;

            byte[] entryData = Utilities.ReadFully(physical.Content, fileEntryPos, _context.PhysicalSectorSize);
            if (!DescriptorTag.IsValid(entryData, 0))
            {
                throw new IOException("Invalid descriptor tag looking for Metadata file entry");
            }

            DescriptorTag dt = Utilities.ToStruct <DescriptorTag>(entryData, 0);

            if (dt.TagIdentifier == TagIdentifier.ExtendedFileEntry)
            {
                ExtendedFileEntry efe = Utilities.ToStruct <ExtendedFileEntry>(entryData, 0);
                _metadataFile = new File(context, physical, efe, _volumeDescriptor.LogicalBlockSize);
            }
            else
            {
                throw new NotImplementedException("Only EFE implemented for Metadata file entry");
            }
        }
示例#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);
        }