Exemple #1
0
        public static byte[] ReadExtent(UdfContext context, LongAllocationDescriptor extent)
        {
            LogicalPartition partition = context.LogicalPartitions[extent.ExtentLocation.Partition];
            long             pos       = extent.ExtentLocation.LogicalBlock * partition.LogicalBlockSize;

            return(Utilities.ReadFully(partition.Content, pos, (int)extent.ExtentLength));
        }
Exemple #2
0
 public File(UdfContext context, Partition partition, FileEntry fileEntry, uint blockSize)
 {
     _context   = context;
     _partition = partition;
     _fileEntry = fileEntry;
     _blockSize = blockSize;
 }
        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");
            }
        }
Exemple #4
0
        public Directory(UdfContext context, LogicalPartition partition, FileEntry fileEntry)
            : base(context, partition, fileEntry, (uint)partition.LogicalBlockSize)
        {
            if (FileContent.Capacity > int.MaxValue)
            {
                throw new NotImplementedException("Very large directory");
            }

            _entries = new List <FileIdentifier>();

            byte[] contentBytes = Utilities.ReadFully(FileContent, 0, (int)FileContent.Capacity);

            int pos = 0;

            while (pos < contentBytes.Length)
            {
                FileIdentifier id   = new FileIdentifier();
                int            size = id.ReadFrom(contentBytes, pos);

                if ((id.FileCharacteristics & (FileCharacteristic.Deleted | FileCharacteristic.Parent)) == 0)
                {
                    _entries.Add(id);
                }

                pos += size;
            }
        }
Exemple #5
0
 public FileContentBuffer(UdfContext context, Partition partition, FileEntry fileEntry, uint blockSize)
 {
     _context   = context;
     _partition = partition;
     _fileEntry = fileEntry;
     _blockSize = blockSize;
     LoadExtents();
 }
Exemple #6
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");
        }
Exemple #7
0
        public static File FromDescriptor(UdfContext context, LongAllocationDescriptor icb)
        {
            LogicalPartition partition = context.LogicalPartitions[icb.ExtentLocation.Partition];

            byte[]        rootDirData = UdfUtilities.ReadExtent(context, icb);
            DescriptorTag rootDirTag  = Utilities.ToStruct <DescriptorTag>(rootDirData, 0);

            if (rootDirTag.TagIdentifier == TagIdentifier.ExtendedFileEntry)
            {
                ExtendedFileEntry fileEntry = Utilities.ToStruct <ExtendedFileEntry>(rootDirData, 0);
                if (fileEntry.InformationControlBlock.FileType == FileType.Directory)
                {
                    return(new Directory(context, partition, fileEntry));
                }
                else
                {
                    return(new File(context, partition, fileEntry, (uint)partition.LogicalBlockSize));
                }
            }
            else if (rootDirTag.TagIdentifier == TagIdentifier.FileEntry)
            {
                FileEntry fileEntry = Utilities.ToStruct <FileEntry>(rootDirData, 0);
                if (fileEntry.InformationControlBlock.FileType == FileType.Directory)
                {
                    return(new Directory(context, partition, fileEntry));
                }
                else
                {
                    return(new File(context, partition, fileEntry, (uint)partition.LogicalBlockSize));
                }
            }
            else
            {
                throw new NotImplementedException("Only ExtendedFileEntries implemented");
            }
        }
Exemple #8
0
 protected LogicalPartition(UdfContext context, LogicalVolumeDescriptor volumeDescriptor)
 {
     _context          = context;
     _volumeDescriptor = volumeDescriptor;
 }