<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using XogarLib.Properties;

namespace XogarLib
{
    public class ThirdPartyGames
    {
        [XmlElement("Games")]
        public List<ThirdPartyGame> games;

        public ThirdPartyGames()
        {
            games = new List<ThirdPartyGame>();
        }

        public void Add(ThirdPartyGame game)
        {
            games.Add(game);
        }

        public IDictionary<String, Game> GetGames()
        {
            Dictionary<String, Game> genericGames = new Dictionary<string, Game>();

            foreach (ThirdPartyGame game in games)
            {
                genericGames.Add(game.Hash(), game);
            }

            return genericGames;
        }

        public void Save()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ThirdPartyGames));
            FileStream stream = new FileStream(Settings.Default.ThirdPartyListing, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            serializer.Serialize(stream, this);
        }

        public static ThirdPartyGames Load()
        {
            XmlSerializer deserialize = new XmlSerializer(typeof(ThirdPartyGames));
            FileStream stream = new FileStream(Settings.Default.ThirdPartyListing, FileMode.Open, FileAccess.Read);

            ThirdPartyGames thirdGames = (ThirdPartyGames)deserialize.Deserialize(stream);

            return thirdGames;
        }
    }
}<commit_msg>Made it so it handles the case of the file not existing.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
using XogarLib.Properties;

namespace XogarLib
{
    public class ThirdPartyGames
    {
        [XmlElement("Games")]
        public List<ThirdPartyGame> games;

        public ThirdPartyGames()
        {
            games = new List<ThirdPartyGame>();
        }

        public void Add(ThirdPartyGame game)
        {
            games.Add(game);
        }

        public IDictionary<String, Game> GetGames()
        {
            Dictionary<String, Game> genericGames = new Dictionary<string, Game>();

            foreach (ThirdPartyGame game in games)
            {
                genericGames.Add(game.Hash(), game);
            }

            return genericGames;
        }

        public void Save()
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ThirdPartyGames));
            FileStream stream = new FileStream(Settings.Default.ThirdPartyListing, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            serializer.Serialize(stream, this);
        }

        public static ThirdPartyGames Load()
        {
            XmlSerializer deserialize = new XmlSerializer(typeof(ThirdPartyGames));

            if (File.Exists(Settings.Default.ThirdPartyListing))
            {
                FileStream stream = new FileStream(Settings.Default.ThirdPartyListing, FileMode.Open, FileAccess.Read);
                ThirdPartyGames thirdGames = (ThirdPartyGames) deserialize.Deserialize(stream);

                return thirdGames;
            }
            
            return new ThirdPartyGames();
        }
    }
}
{'fraction_non_alphanumeric': 0.08395291201982652, 'fraction_numerical': 0.0, 'mean_word_length': 2.1441090555014606, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3597249', 'n_tokens_mistral': 888, 'n_tokens_neox': 812, 'n_words': 181}