<commit_before>using System;
using System.Collections.Generic;
using System.IO;

namespace AlmWitt.Web.ResourceManagement
{
	/// <summary>
	/// Represents a collection of resources that have been consolidated
	/// into one resource.
	/// </summary>
	public class ConsolidatedResource
	{
		private readonly ResourceCollection _resources;
		private readonly DateTime _lastModified;
		private readonly MemoryStream _contentStream;

		internal ConsolidatedResource(ResourceCollection resources, MemoryStream consolidatedContent)
		{
			_resources = resources;
			_lastModified = resources.LastModified;
			_contentStream = consolidatedContent;
		}

		/// <summary>
		/// Gets the most recent last modified date of the resources the consolidated resources.
		/// </summary>
		public DateTime LastModified
		{
			get { return _lastModified; }
		}

		/// <summary>
		/// Gets the resources that were consolidated.
		/// </summary>
		public IEnumerable<IResource> Resources
		{
			get { return _resources; }
		}

		/// <summary>
		/// Gets a stream to the consolidated content.
		/// </summary>
		public MemoryStream ContentStream
		{
			get
			{
				return _contentStream;
			}
		}

		/// <summary>
		/// Writes the contents of the consolidated resource to a file.
		/// </summary>
		/// <param name="path">The full path of the file to be written to.</param>
		public void WriteToFile(string path)
		{
			using(Stream outputStream = new FileStream(path, FileMode.Create))
			{
				WriteTo(outputStream);
			}
		}

		public void WriteTo(Stream outputStream)
		{
			if(ContentStream.Length > 0)
			{
				ContentStream.WriteTo(outputStream);	
			}
		}<commit_msg>Fixed bug that was reintroduced that ensures that consolidated file can be pre-consolidated to a directory that does not yet exist.<commit_after>using System;
using System.Collections.Generic;
using System.IO;

namespace AlmWitt.Web.ResourceManagement
{
	/// <summary>
	/// Represents a collection of resources that have been consolidated
	/// into one resource.
	/// </summary>
	public class ConsolidatedResource
	{
		private readonly ResourceCollection _resources;
		private readonly DateTime _lastModified;
		private readonly MemoryStream _contentStream;

		internal ConsolidatedResource(ResourceCollection resources, MemoryStream consolidatedContent)
		{
			_resources = resources;
			_lastModified = resources.LastModified;
			_contentStream = consolidatedContent;
		}

		/// <summary>
		/// Gets the most recent last modified date of the resources the consolidated resources.
		/// </summary>
		public DateTime LastModified
		{
			get { return _lastModified; }
		}

		/// <summary>
		/// Gets the resources that were consolidated.
		/// </summary>
		public IEnumerable<IResource> Resources
		{
			get { return _resources; }
		}

		/// <summary>
		/// Gets a stream to the consolidated content.
		/// </summary>
		public MemoryStream ContentStream
		{
			get
			{
				return _contentStream;
			}
		}

		/// <summary>
		/// Writes the contents of the consolidated resource to a file.
		/// </summary>
		/// <param name="path">The full path of the file to be written to.</param>
		public void WriteToFile(string path)
		{
			//ensure the destination directory exists
			string directory = Path.GetDirectoryName(path);
			Directory.CreateDirectory(directory);
			
			using(Stream outputStream = new FileStream(path, FileMode.Create))
			{
				WriteTo(outputStream);
			}
		}

		public void WriteTo(Stream outputStream)
		{
			if(ContentStream.Length > 0)
			{
				ContentStream.WriteTo(outputStream);	
			}
		}
{'fraction_non_alphanumeric': 0.09621318373071529, 'fraction_numerical': 0.0005610098176718093, 'mean_word_length': 3.2860576923076925, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3623141', 'n_tokens_mistral': 1149, 'n_tokens_neox': 961, 'n_words': 305}