public static bool TryFromStream(Stream stream, out DescriptorTag result) { byte[] next = Utilities.ReadFully(stream, 512); if (!DescriptorTag.IsValid(next, 0)) { result = null; return(false); } DescriptorTag dt = new DescriptorTag(); dt.ReadFrom(next, 0); result = dt; return(true); }
public int ReadFrom(byte[] buffer, int offset) { if (!DescriptorTag.IsValid(buffer, offset)) { throw new InvalidDataException("Invalid Anchor Volume Descriptor Pointer (invalid tag)"); } Tag = new DescriptorTag(); Tag.ReadFrom(buffer, offset); if (UdfUtilities.ComputeCrc(buffer, offset + Tag.Size, Tag.DescriptorCrcLength) != Tag.DescriptorCrc) { throw new InvalidDataException("Invalid Anchor Volume Descriptor Pointer (invalid CRC)"); } return(Parse(buffer, offset)); }
protected static List <ExtendedAttributeRecord> ReadExtendedAttributes(byte[] eaData) { if (eaData != null && eaData.Length != 0) { DescriptorTag eaTag = new DescriptorTag(); eaTag.ReadFrom(eaData, 0); int implAttrLocation = Utilities.ToInt32LittleEndian(eaData, 16); int appAttrLocation = Utilities.ToInt32LittleEndian(eaData, 20); List <ExtendedAttributeRecord> extendedAttrs = new List <ExtendedAttributeRecord>(); int pos = 24; while (pos < eaData.Length) { ExtendedAttributeRecord ea; if (pos >= implAttrLocation) { ea = new ImplementationUseExtendedAttributeRecord(); } else { ea = new ExtendedAttributeRecord(); } int numRead = ea.ReadFrom(eaData, pos); extendedAttrs.Add(ea); pos += numRead; } return(extendedAttrs); } else { return(null); } }