private void SetProject(Gibbed.ProjectData.Project project)
        {
            if (project != null)
            {
                try
                {
                    this.FileHashLookup = project.LoadListsFileNames();
                    this.TypeHashLookup = project.LoadListsTypeNames();

                    this.openDialog.InitialDirectory = project.InstallPath;
                    this.saveKnownFileListDialog.InitialDirectory = project.ListsPath;
                }
                catch (Exception e)
                {
                    MessageBox.Show(
                        "There was an error while loading project data." +
                        Environment.NewLine + Environment.NewLine +
                        e.ToString() +
                        Environment.NewLine + Environment.NewLine +
                        "(You can press Ctrl+C to copy the contents of this dialog)",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    project = null;
                }
            }

            if (project != this.Manager.ActiveProject)
            {
                this.Manager.ActiveProject = project;
            }

            this.projectComboBox.SelectedItem = project;
        }
        private void OnReloadLists(object sender, EventArgs e)
        {
            if (this.Manager.ActiveProject != null)
            {
                this.FileHashLookup = this.Manager.ActiveProject.LoadListsFileNames();
                this.TypeHashLookup = this.Manager.ActiveProject.LoadListsTypeNames();
            }

            this.BuildFileTree();
        }
        public void ShowSaveProgress(
            IWin32Window owner,
            Stream stream,
            ERF archive,
            IEnumerable <ERF.Entry> saving,
            Gibbed.ProjectData.HashList <ulong> fileNames,
            Gibbed.ProjectData.HashList <uint> typeNames,
            string basePath,
            SaveAllSettings settings)
        {
            this.Info.BasePath  = basePath;
            this.Info.Stream    = stream;
            this.Info.Archive   = archive;
            this.Info.Saving    = saving;
            this.Info.FileNames = fileNames;
            this.Info.TypeNames = typeNames;
            this.Info.Settings  = settings;

            this.progressBar.Value   = 0;
            this.progressBar.Maximum = 100;

            this.SaveThread = new Thread(new ParameterizedThreadStart(SaveAll));
            this.ShowDialog(owner);
        }
 public EntryComparer(Gibbed.ProjectData.HashList <ulong> names)
 {
     this.FileNames = names;
 }
        private static void GuessExtensions(Gibbed.ProjectData.HashList <uint> hashes)
        {
            var extensionGroups = new[]
            {
                new[]
                {
                    //".ddsc", // Causes unnecessary collisions.
                    ".atx1", ".atx2", /*".atx3", ".atx4", ".atx5", ".atx6", ".atx7", ".atx8", ".atx9",*/
                },
                new[]
                {
                    ".ee", ".epe", ".epe_adf", ".wtunec", ".ftunec",
                    null,
                    ".resourcebundle",
                },
                new[]
                {
                    ".bl", ".blo", ".blo_adf", ".blo.mdic",
                    ".fl", ".flo", ".flo_adf", ".fl.mdic",
                    ".nl", ".nl.mdic",
                    ".pfx_breakablecompoundc",
                    ".pfx_staticcompoundc",
                    ".obc",
                    null,
                    ".resourcebundle",
                },
            };

            var oldNames = hashes.GetStrings().ToArray();

            foreach (var oldName in oldNames)
            {
                foreach (var extensionGroup in extensionGroups)
                {
                    string oldExtension = null;
                    int    oldIndex     = -1;
                    for (int i = 0; i < extensionGroup.Length; i++)
                    {
                        var extension = extensionGroup[i];
                        if (extension == null)
                        {
                            break;
                        }

                        if (oldName.EndsWith(extension) == true)
                        {
                            oldExtension = extension;
                            oldIndex     = i;
                            break;
                        }
                    }

                    if (oldExtension == null)
                    {
                        continue;
                    }

                    for (int i = 0; i < extensionGroup.Length; i++)
                    {
                        if (i == oldIndex)
                        {
                            continue;
                        }

                        var newExtension = extensionGroup[i];
                        if (newExtension == null)
                        {
                            continue;
                        }

                        var newName = oldName.Substring(0, oldName.Length - oldExtension.Length) + newExtension;
                        var newHash = newName.HashJenkins();

                        if (hashes.Contains(newHash) == true)
                        {
                            var existingName = hashes[newHash];
                            if (existingName != newName)
                            {
                                throw new InvalidOperationException(
                                          string.Format(
                                              "hash collision ('{0}' vs '{1}')",
                                              existingName,
                                              newName));
                            }
                        }
                        else
                        {
                            hashes.Add(newHash, newName);
                        }
                    }
                }
            }
        }