Beispiel #1
0
        // ---

        #region Extraction
        protected void ExtractDataFiles(DataRep g, string tmpPath)
        {
            string fileExt = Path.GetExtension(g.CurrentPath).TrimStart('.');

            // Détection du mode
            if (fileExt.Equals("zip", StringComparison.OrdinalIgnoreCase))
            {
                // Extraction des fichiers
                ZipDecompression zippy = new ZipDecompression()
                {
                    TokenSource = this.TokenSource,
                    IsPaused    = this.IsPaused,
                };
                zippy.ExtractSpecificFiles(g.CurrentPath, tmpPath, "DPGame.json", "NBGame.xml", "TBGame.xml", "EBGame.xml");
            }

            else if (fileExt.Equals("7zip", StringComparison.OrdinalIgnoreCase) || fileExt.Equals("7z", StringComparison.OrdinalIgnoreCase))
            {
                // Extraction des fichiers
                SevenZipDecompression sevZipp = new SevenZipDecompression()
                {
                    TokenSource = this.TokenSource,
                    IsPaused    = this.IsPaused,
                };
                sevZipp.ExtractSpecificFiles(g.CurrentPath, tmpPath, "DPGame.json", "NBGame.xml", "TBGame.xml", "EBGame.xml");
            }
            else
            {
                throw new Exception("File format not managed");
            }
        }
Beispiel #2
0
        private void Depack7Zip(string pathLink, string tmpPath)
        {
            // Extraction des fichiers
            SevenZipDecompression sevZippy = new SevenZipDecompression()
            {
                TokenSource = this.TokenSource,
                IsPaused    = this.IsPaused,
            };

            SafeBoxes.LaunchDouble(sevZippy, () => sevZippy.ExtractAll(pathLink, tmpPath), "Zip Extraction");
        }
Beispiel #3
0
        void DPG7ZipCore(DataRep zF, string gamePath)
        {
            // Extraction des fichiers xml
            SevenZipDecompression zippy = new SevenZipDecompression()
            {
                TokenSource = this.TokenSource,
                IsPaused    = this.IsPaused,
            };

            SafeBoxes.LaunchDouble(zippy, () => zippy.ExtractSpecificFiles(zF.CurrentPath, gamePath,
                                                                           "NBGame.xml", "TBGame.xml", "EBGame.xml", "DPGame.json"),
                                   "SevenZip Extraction");
        }
Beispiel #4
0
        /*
         * private void SetSelected(GamePaths gpX, GameDataCont gpC)
         * {
         *  var app = gpC.Apps.FirstOrDefault(x => x.ALinkToThePath.Equals(gpX.ApplicationPath));
         *  if (app != null)
         *      app.IsSelected = true;
         *  var manual = gpC.Apps.FirstOrDefault(x => x.ALinkToThePath.Equals(gpX.ApplicationPath));
         *  var music = gpC.Apps.FirstOrDefault(x => x.ALinkToThePath.Equals(gpX.ApplicationPath));
         *  var video = gpC.Apps.FirstOrDefault(x => x.ALinkToThePath.Equals(gpX.ApplicationPath));
         *  var themevideo = gpC.Apps.FirstOrDefault(x => x.ALinkToThePath.Equals(gpX.ApplicationPath));
         * }*/

        /// <summary>
        /// On rajoute les fichiers présents sur le disque dur
        /// </summary>
        /// <param name="gpC"></param>
        /// <param name="mode"></param>
        /// <param name="archiveName"></param>
        private void GameDataCompletion(GameDataCont gpC, ArchiveMode mode, string archiveName)
        {
            IEnumerable <string> files = null;

            if (mode == ArchiveMode.Zip)
            {
                files = ZipDecompression.StaticGetAllFiles(archiveName);
                files = files.Select(f => f.Replace('/', '\\'));
            }
            else if (mode == ArchiveMode.SevenZip)
            {
                files = SevenZipDecompression.StaticGetAllFiles(archiveName);
            }
            else if (mode == ArchiveMode.Folder)
            {
                files = Directory.GetFiles(archiveName, "*.*", SearchOption.AllDirectories);
                files = files.Select(f => f.Replace($@"{archiveName}\", string.Empty));
            }
            else
            {
                throw new Exception("Not supported");
            }


            // Vérification des fichiers entrés via le GamePaths;
            string tmp;

            //   gpC.SSetApplications = GameDataCompletion(files, Default.Games, "\\", "\\");
            foreach (DataPlus app in gpC.Applications.ToList())
            {
                tmp = $@"{Config.Games}{app.CurrentPath?.Substring(1)}";

                // Récupération du fichier correspondant
                var f = files.FirstOrDefault(x => x.StartsWith(tmp));

                // Si correspondance trouvée
                if (!string.IsNullOrEmpty(f))
                {
                    continue;
                }

                HeTrace.WriteLine($"File not found {app.CurrentPath}");
                f = files.FirstOrDefault(x => Path.GetFileName(x).Equals(Path.GetFileName(app.CurrentPath)));

                // Si remplacement possible
                if (!string.IsNullOrEmpty(f))
                {
                    app.CurrentPath = f.Replace(Config.Games, ".");
                    HeTrace.WriteLine($"Changed by {app.CurrentPath}");
                }
                else
                {
                    HeTrace.WriteLine("Removed");
                    gpC.RemoveApp(app);
                }
            }


            gpC.SetSCheatCodes = GameDataCompletion(files, Config.CheatCodes, "\\", "\\");
            // Manuals
            var tmp2 = $@"{Config.Manuals}{gpC.DefaultManual?.CurrentPath.Substring(1)}";

            if (!files.Contains(tmp2))
            {
                gpC.UnsetDefaultManual();
            }
            gpC.AddSManuals = GameDataCompletion(files, Config.Manuals, "\\", "\\");
            // Musics
            if (!files.Contains($@"{Config.Musics}{gpC.DefaultMusic?.CurrentPath.Substring(1)}"))
            {
                gpC.UnsetDefaultMusic();
            }
            gpC.AddSMusics = GameDataCompletion(files, Config.Musics, "\\", "\\");
            // Videos
            if (!files.Contains($@"{Config.Videos}{gpC.DefaultVideo?.CurrentPath.Substring(1)}"))
            {
                gpC.UnsetDefaultVideo();
            }

            if (!files.Contains($@"{Config.Videos}{gpC.DefaultThemeVideo?.CurrentPath.Substring(1)}"))
            {
                gpC.UnsetDefaultThemeVideo();
            }

            gpC.AddSVideos = GameDataCompletion(files, Config.Videos, "\\", "\\");
        }