public void RestoreFromBackups()
        {
            CloseDatafiles();

            foreach (var texturesFilePath in DataFiles.Keys)
            {
                string tableFilePath   = Path.Combine(Path.GetDirectoryName(texturesFilePath), Path.GetFileName(texturesFilePath).Replace("textures", "texture_table"));
                string backupTablePath = Path.Combine(Settings.FileName(Path.ChangeExtension(Path.GetFileName(tableFilePath), ".bak")));
                if (File.Exists(backupTablePath))
                {
                    File.Copy(backupTablePath, tableFilePath, true);
                    long size = Settings.GetFileSize(texturesFilePath);
                    if (size != 0)
                    {
                        using FileStream file = File.OpenWrite(texturesFilePath);
                        file.SetLength(size);

                        var list         = Lists[texturesFilePath];
                        var originalList = new TextureList(tableFilePath, texturesFilePath);
                        foreach (var info in list)
                        {
                            if (info.offset >= size)
                            {
                                var previous = originalList.First(n => n.name == info.name);
                                info.offset = previous.offset;
                                info.length = previous.length;
                                OnTextureChangeDiscarded?.Invoke(info);
                            }
                        }
                    }
                }
            }

            nonOriginalCount = 0;
        }
        public bool Load(string installationPath)
        {
            Clear();

            RootPath = installationPath;

            try
            {
                int fileIndex = 1;
                dataFolder = Path.Combine(installationPath, "data");

                string texturesFile = Path.Combine(dataFolder, "textures");
                string tableFile    = Path.Combine(dataFolder, "texture_table");
                while (File.Exists(texturesFile) && File.Exists(tableFile))
                {
                    DataFiles[texturesFile] = File.OpenRead(texturesFile);
                    Lists[texturesFile]     = new TextureList(tableFile, texturesFile);

                    foreach (var file in Lists[texturesFile])
                    {
                        AddFoldersInPath(file.name);
                        if (file.original == false)
                        {
                            nonOriginalCount++;
                        }
                    }

                    fileIndex++;
                    texturesFile = Path.Combine(dataFolder, $"textures{fileIndex:D2}");
                    tableFile    = Path.Combine(dataFolder, $"texture_table{fileIndex:D2}");
                }
            }
            catch (Exception)
            {
                Lists.Clear();
                DataFiles.Clear();
                return(false);
            }

            SaveBackups();
            return(true);

            void AddFoldersInPath(string path)
            {
                var directory = Path.GetDirectoryName(path);

                if (directory != "")
                {
                    Folders.Add(directory);
                    AddFoldersInPath(directory);
                }
            }
        }