/// <summary> /// Parse the children based on the data in this directory. /// </summary> /// <param name="s">The stream to parse from.</param> /// <param name="visited">The set of already handled /// files/directories.</param> public void Parse(Stream s, Dictionary<long, ISONode> visited) { // Go to the beginning of the set of directories s.Seek(this.Offset*ISOFile.SECTOR_SIZE, SeekOrigin.Begin); List<ISONodeRecord> records = new List<ISONodeRecord>(); // Read the directory entries while(s.Position < ((this.Offset*ISOFile.SECTOR_SIZE)+this.Length)) { ISONode node; ISONodeRecord record; // Read the record record = new ISONodeRecord(); record.Parse(s); // Check if we already have this node if (visited.ContainsKey(record.OffsetOfData)) { // Get the node node = visited[record.OffsetOfData]; } else { // Create the node from the record if (record.IsFile()) { node = new ISOFileNode(record); } else if (record.IsDirectory()) { node = new ISODirectoryNode(record); } else { node = new ISONode(record); } // Keep track that we've now seen the node and are parsing it visited.Add(node.Offset, node); } // Add the node as a child this.Children.Add(record.Name, node); } long currentPosition = s.Position; // Iterate over directories... foreach(KeyValuePair<string,ISONode> child in this.Children) { // Parse this node if( child.Key != ISONodeRecord.CURRENT_DIRECTORY && child.Key != ISONodeRecord.PARENT_DIRECTORY && child.Value is ISODirectoryNode ) { ((ISODirectoryNode)child.Value).Parse(s, visited); } } s.Seek(currentPosition, SeekOrigin.Begin); }
/// <summary> /// Constructor. /// </summary> public ISOVolumeDescriptor() { // Set everything to the default value this.Type = 0; this.SystemIdentifier = new byte[LENGTH_SHORT_IDENTIFIER]; this.VolumeIdentifier = new byte[LENGTH_SHORT_IDENTIFIER]; this.NumberOfSectors = 0; this.VolumeSetSize = 1; this.VolumeSequenceNumber = 1; this.SectorSize = ISOFile.SECTOR_SIZE; this.PathTableSize = 0; this.OffsetOfFirstLittleEndianPathTable = 0; this.OffsetOfSecondLittleEndianPathTable = 0; this.OffsetOfFirstBigEndianPathTable = 0; this.OffsetOfSecondBigEndianPathTable = 0; this.RootDirectoryRecord = new ISONodeRecord(); this.VolumeSetIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.PublisherIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.DataPreparerIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.ApplicationIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.CopyrightFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.AbstractFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.BibliographicalFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.VolumeCreationDateTime = new byte[LENGTH_TIME]; this.LastModifiedDateTime = new byte[LENGTH_TIME]; this.ExpirationDateTime = new byte[LENGTH_TIME]; this.EffectiveDateTime = new byte[LENGTH_TIME]; this.Reserved = new byte[LENGTH_RESERVED]; // CD-I specific this.VolumeFlags = 0; this.CodedCharSetIdent = new byte[LENGTH_SHORT_IDENTIFIER]; this.AddressOfPathTable = 0; }
/// <summary> /// Constructor. /// TODO: Make this constructor protected??? /// </summary> /// <param name="record">The ISONodeRecord to construct from.</param> public ISONode(ISONodeRecord record) { this.FirstRecord = record; this.Offset = record.OffsetOfData; this.Length = record.LengthOfData; }
/// <summary> /// Constructor. /// TODO: Make this constructor protected??? /// </summary> /// <param name="record">The ISONodeRecord to construct from.</param> public ISONode( ISONodeRecord record ) { this.FirstRecord = record; this.Offset = record.OffsetOfData; this.Length = record.LengthOfData; }
/// <summary> /// Parse the children based on the data in this directory. /// </summary> /// <param name="s">The stream to parse from.</param> /// <param name="visited">The set of already handled /// files/directories.</param> public void Parse(Stream s, Dictionary <long, ISONode> visited) { // Go to the beginning of the set of directories s.Seek(this.Offset * ISOFile.SECTOR_SIZE, SeekOrigin.Begin); List <ISONodeRecord> records = new List <ISONodeRecord>(); // Read the directory entries while (s.Position < ((this.Offset * ISOFile.SECTOR_SIZE) + this.Length)) { ISONode node; ISONodeRecord record; // Read the record record = new ISONodeRecord(); if (ISOFile.Format == ISOFile.ISOFormat.CDInteractive) { record.ParseCDInteractive(s); } if (ISOFile.Format == ISOFile.ISOFormat.ISO9660) { record.ParseISO9660(s); } //zero 24-jun-2013 - improved validity checks //theres nothing here! if (record.Length == 0) { break; } else { // Check if we already have this node if (visited.ContainsKey(record.OffsetOfData)) { // Get the node node = visited[record.OffsetOfData]; } else { // Create the node from the record if (record.IsFile()) { node = new ISOFileNode(record); } else if (record.IsDirectory()) { node = new ISODirectoryNode(record); } else { node = new ISONode(record); } // Keep track that we've now seen the node and are parsing it visited.Add(node.Offset, node); } // Add the node as a child if (!this.Children.ContainsKey(record.Name)) { this.Children.Add(record.Name, node); } } } long currentPosition = s.Position; // Iterate over directories... foreach (KeyValuePair <string, ISONode> child in this.Children) { // Parse this node if (child.Key != ISONodeRecord.CURRENT_DIRECTORY && child.Key != ISONodeRecord.PARENT_DIRECTORY && child.Value is ISODirectoryNode dirNode) { dirNode.Parse(s, visited); } } s.Seek(currentPosition, SeekOrigin.Begin); }
/// <summary> /// Constructor. /// </summary> /// <param name="record">The node for this directory.</param> public ISODirectoryNode(ISONodeRecord record) : base(record) { this.Children = new Dictionary <string, ISONode>(); }
/// <summary> /// Constructor. /// </summary> /// <param name="record">The node for this directory.</param> public ISODirectoryNode( ISONodeRecord record ) : base(record) { this.Children = new Dictionary<string, ISONode>(); }
/// <summary> /// Constructor. /// </summary> public ISOVolumeDescriptor() { // Set everything to the default value this.Type = 0; this.SystemIdentifier = new byte[LENGTH_SHORT_IDENTIFIER]; this.VolumeIdentifier = new byte[LENGTH_SHORT_IDENTIFIER]; this.NumberOfSectors = 0; this.VolumeSetSize = 1; this.VolumeSequenceNumber = 1; this.SectorSize = ISOFile.SECTOR_SIZE; this.PathTableSize = 0; this.OffsetOfFirstLittleEndianPathTable = 0; this.OffsetOfSecondLittleEndianPathTable = 0; this.OffsetOfFirstBigEndianPathTable = 0; this.OffsetOfSecondBigEndianPathTable = 0; this.RootDirectoryRecord = new ISONodeRecord(); this.VolumeSetIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.PublisherIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.DataPreparerIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.ApplicationIdentifier = new byte[LENGTH_LONG_IDENTIFIER]; this.CopyrightFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.AbstractFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.BibliographicalFileIdentifier = new byte[LENGTH_IDENTIFIER]; this.VolumeCreationDateTime = new byte[LENGTH_TIME]; this.LastModifiedDateTime = new byte[LENGTH_TIME]; this.ExpirationDateTime = new byte[LENGTH_TIME]; this.EffectiveDateTime = new byte[LENGTH_TIME]; this.Reserved = new byte[LENGTH_RESERVED]; }
/// <summary> /// Constructor. /// </summary> /// <param name="record">The record to construct from.</param> public ISOFileNode( ISONodeRecord record ) : base(record) { // Do Nothing }
/// <summary> /// Constructor. /// </summary> /// <param name="record">The record to construct from.</param> public ISOFileNode(ISONodeRecord record) : base(record) { // Do Nothing }