<commit_before>﻿// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Text;

namespace CefSharp
{
    /// <summary>
    /// FileResourceHandler  is used as a placeholder class which uses native CEF implementations.
    /// CefStreamReader::CreateForFile is used to create a CefStreamReader instance which is passed to
    /// a new instance of CefStreamResourceHandler
    /// (Was previously ResourceHandlerType::File to differentiate, going for a more flexible approach now)
    /// TODO: Move this class into Handler namespace 
    /// </summary>
    public class FileResourceHandler : IResourceHandler
    {
        /// <summary>
        /// Path of the underlying file
        /// </summary>
        public string FilePath { get; private set; }

        /// <summary>
        /// Gets or sets the Mime Type.
        /// </summary>
        public string MimeType { get; set; }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="FileResourceHandler"/> class.
        /// </summary>
        /// <param name="mimeType">mimeType</param>
        /// <param name="filePath">filePath</param>
        public FileResourceHandler(string mimeType, string filePath)
        {
            if(string.IsNullOrEmpty(mimeType))
            {
                throw new ArgumentNullException("mimeType", "Please provide a valid mimeType");
            }

            if(string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath", "Please provide a valid filePath");
            }

            <commit_msg>FileResourceHandler - Throw exception if file not found<commit_after>﻿// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using System.IO;

namespace CefSharp
{
    /// <summary>
    /// FileResourceHandler  is used as a placeholder class which uses native CEF implementations.
    /// CefStreamReader::CreateForFile is used to create a CefStreamReader instance which is passed to
    /// a new instance of CefStreamResourceHandler
    /// (Was previously ResourceHandlerType::File to differentiate, going for a more flexible approach now)
    /// TODO: Move this class into Handler namespace 
    /// </summary>
    public class FileResourceHandler : IResourceHandler
    {
        /// <summary>
        /// Path of the underlying file
        /// </summary>
        public string FilePath { get; private set; }

        /// <summary>
        /// Gets or sets the Mime Type.
        /// </summary>
        public string MimeType { get; set; }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="FileResourceHandler"/> class.
        /// </summary>
        /// <param name="mimeType">mimeType</param>
        /// <param name="filePath">filePath</param>
        public FileResourceHandler(string mimeType, string filePath)
        {
            if(string.IsNullOrEmpty(mimeType))
            {
                throw new ArgumentNullException("mimeType", "Please provide a valid mimeType");
            }

            if(string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException("filePath", "Please provide a valid filePath");
            }

            if(!File.Exists(filePath))
            {
                throw new FileNotFoundException("Unable to create FileResourceHandler", filePath);
            }
            
{'fraction_non_alphanumeric': 0.0977765871952853, 'fraction_numerical': 0.004286096972944013, 'mean_word_length': 2.151054852320675, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '4216428', 'n_tokens_mistral': 947, 'n_tokens_neox': 905, 'n_words': 326}