Ejemplo n.º 1
0
		/// <summary>
		/// Stream constructor.
		/// </summary>
		/// <param name="stream">The stream that contains the DirectorySector data.</param>
		public DirectorySector(Stream stream)
		{
			Debug.Assert(stream.Length >= Constants.SECTOR_SIZE);

			for(int i = 0; i < _entries.Length; ++i)
				_entries[i] = new DirectorySectorEntry(stream);
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Stream constructor.
        /// </summary>
        /// <param name="stream">The stream that contains the DirectorySector data.</param>
        public DirectorySector(Stream stream)
        {
            Debug.Assert(stream.Length >= Constants.SECTOR_SIZE);

            for (int i = 0; i < _entries.Length; ++i)
            {
                _entries[i] = new DirectorySectorEntry(stream);
            }
        }
		/// <summary>
		/// Builds a directory entry and populates its correct type, children and siblings.
		/// </summary>
		/// <param name="entry">The directory sector entry.</param>
		/// <param name="entries">The current entries.</param>
		/// <param name="sectors">The data sectors.</param>
		/// <param name="fat">The FAT.</param>
		/// <returns>The correct DirectoryEntry object.</returns>
		public static DirectoryEntry CreateEntry(DirectorySectorEntry entry, 
			DirectorySectorEntryCollection entries, 
			SectorCollection sectors, 
			Sect[] fat)
		{
			DirectoryEntry newEntry = null;
			switch(entry.Type)
			{
				case Stgty.Storage :
					newEntry = new StorageEntry(entry.Name);
					break;
				case Stgty.Stream :
					newEntry = new StreamEntry(entry.Name, entry.Size, entry.SectStart, sectors, fat);
					break;
				default:
					newEntry = new GenericDirectoryEntry(entry.Name, entry.Type);
					break;
			}

			if(!entry.LeftSibling.IsEof)
				newEntry.LeftSibling = CreateEntry(entries[entry.LeftSibling],
					entries,
					sectors,
					fat);

			if(!entry.RightSibling.IsEof)
				newEntry.RightSibling = CreateEntry(entries[entry.RightSibling],
					entries,
					sectors,
					fat);

			if(!entry.Child.IsEof)
				newEntry.Child = CreateEntry(entries[entry.Child],
					entries,
					sectors,
					fat);

			return newEntry;
		}