예제 #1
0
        private List <string> GetFilesFromGameFileSettings(IGameFile gameFile, LauncherPath gameFileDirectory, LauncherPath tempDirectory, bool checkSpecific, string[] extensions)
        {
            List <string> files = new List <string>();

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine(gameFileDirectory.GetFullPath(), gameFile.FileName)))
            {
                var entries = za.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains('.') &&
                                               extensions.Any(y => y.Equals(Path.GetExtension(x.Name), StringComparison.OrdinalIgnoreCase)));

                foreach (ZipArchiveEntry zae in entries)
                {
                    bool useFile = true;

                    if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                    {
                        useFile = SpecificFiles.Contains(zae.FullName);
                    }

                    if (useFile)
                    {
                        string extractFile = Path.Combine(tempDirectory.GetFullPath(), zae.Name);
                        if (ExtractFiles)
                        {
                            zae.ExtractToFile(extractFile, true);
                        }
                        files.Add(extractFile);
                    }
                }
            }

            return(files);
        }
예제 #2
0
        private void ResetSpecificFilesSelections(IGameFile[] selectedFiles)
        {
            foreach (IGameFile gameFile in selectedFiles)
            {
                if (SpecificFiles == null)
                {
                    SpecificFiles = GetSupportedFiles(GameFile);
                }

                SpecificFiles = SpecificFiles.Union(GetSupportedFiles(gameFile)).ToArray();
            }
        }
예제 #3
0
 private void CtrlFiles_ItemRemoving(object sender, AdditionalFilesEventArgs e)
 {
     if (e.Item.Equals(GameFile))
     {
         MessageBox.Show(this, string.Format("Cannot remove {0}. This is the file you will be launching!", GameFile.FileName),
                         "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
         e.Cancel = true;
     }
     else
     {
         if (SpecificFiles != null)
         {
             SpecificFiles = SpecificFiles.Except(GetSupportedFiles((IGameFile)e.Item)).ToArray();
         }
     }
 }
예제 #4
0
        private List <string> GetFilesFromGameFileSettings(IGameFile gameFile, LauncherPath gameFileDirectory, LauncherPath tempDirectory,
                                                           bool checkSpecific, string[] extensions)
        {
            List <string> files = new List <string>();

            using (IArchiveReader reader = CreateArchiveReader(gameFile, gameFileDirectory))
            {
                IEnumerable <IArchiveEntry> entries;
                if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                {
                    entries = reader.Entries;
                }
                else
                {
                    entries = reader.Entries.Where(x => !string.IsNullOrEmpty(x.Name) && x.Name.Contains('.') &&
                                                   extensions.Any(y => y.Equals(Path.GetExtension(x.Name), StringComparison.OrdinalIgnoreCase)));
                }

                foreach (IArchiveEntry entry in entries)
                {
                    bool useFile = true;
                    if (checkSpecific && SpecificFiles != null && SpecificFiles.Length > 0)
                    {
                        useFile = SpecificFiles.Contains(entry.FullName);
                    }

                    if (useFile)
                    {
                        if (entry.ExtractRequired)
                        {
                            string extractFile = Path.Combine(tempDirectory.GetFullPath(), entry.Name);
                            if (ExtractFiles)
                            {
                                entry.ExtractToFile(extractFile, true);
                            }
                            files.Add(extractFile);
                        }
                        else
                        {
                            files.Add(entry.FullName);
                        }
                    }
                }
            }

            return(files);
        }