<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using EpubSharp.Format;
using EpubSharp.Format.Readers;

namespace EpubSharp
{
    public static class EpubReader
    {
        public static EpubBook Read(string filePath, Encoding encoding = null)
	    {
            if (filePath == null) throw new ArgumentNullException(nameof(filePath));
            if (encoding == null) encoding = Constants.DefaultEncoding;

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("Specified epub file not found.", filePath);
            }

            return Read(File.Open(filePath, FileMode.Open, FileAccess.Read), false, encoding);
        }

        public static EpubBook Read(byte[] epubData, Encoding encoding = null)<commit_msg>Allow multiple processes open the same fil when using EpubReader.Read()<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using EpubSharp.Format;
using EpubSharp.Format.Readers;

namespace EpubSharp
{
    public static class EpubReader
    {
        public static EpubBook Read(string filePath, Encoding encoding = null)
	    {
            if (filePath == null) throw new ArgumentNullException(nameof(filePath));
            if (encoding == null) encoding = Constants.DefaultEncoding;

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("Specified epub file not found.", filePath);
            }

            return Read(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read), false, encoding);
        }

        public static EpubBook Read(byte[] epubData, Encoding encoding = null)
{'fraction_non_alphanumeric': 0.09086021505376345, 'fraction_numerical': 0.0, 'mean_word_length': 3.036876355748373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3358191', 'n_tokens_mistral': 512, 'n_tokens_neox': 498, 'n_words': 143}