示例#1
0
        private void CopyClones(LBGame lBGame, string destLocation)
        {
            //ITrace.WriteLine(prefix: false);

            /* 26/03/2021
             * OPFiles opF = new OPFiles()
             * {
             *  Buttons = Dcs_Buttons.NoStop,
             *  WhoCallMe = "Clone"
             * };
             * opF.IWriteLine += (string message) => ITrace.WriteLine(message);
             * opF.IWrite += (string message) => ITrace.BeginLine(message);*/

            List <Clone> clones = XML_Games.ListClones(_XMLPlatformFile, "GameID", lBGame.Id).ToList();

            // tri des doublons / filter duplicates
            List <Clone> fClones = FilesFunc.DistinctClones(clones, lBGame.ApplicationPath, PS.Default.LBPath);

            // On va vérifier que chaque clone n'est pas déjà présent et selon déjà copier
            foreach (Clone zeClone in fClones)
            {
                //waiting zeClone.ApplicationPath = ReconstructPath(zeClone.ApplicationPath);

                SimpleCopyManager(Path.GetFullPath(zeClone.ApplicationPath, PS.Default.LBPath), destLocation, ref _FileConflictDecision);
            }
        }
示例#2
0
        internal static Dictionary <string, bool?> CheckGameValidity(ShortGame g, string platformXmlFile)
        {
            LBGame game = XML_Games.Scrap_LBGame <LBGame>(platformXmlFile, GameTag.ID, g.Id);

            //clones
            var clones = XML_Games.ListClones(platformXmlFile, Tag.GameId, g.Id);

            bool bMG = CheckValidity(game.ApplicationPath);

            if (!bMG)
            {
                return(null);
            }

            Dictionary <string, bool?> yEP = new Dictionary <string, bool?>();

            yEP.Add("Main Game", bMG);
            yEP.Add("Manual", CheckValidity(game.ManualPath));
            yEP.Add("Music", CheckValidity(game.MusicPath));
            yEP.Add("Video", CheckValidity(game.VideoPath));
            yEP.Add("ThemeVideo", CheckValidity(game.ThemeVideoPath));

            foreach (var c in clones)
            {
                yEP.Add(Path.GetFileName(c.ApplicationPath), CheckValidity(c.ApplicationPath));
            }

            return(yEP);

            /// <summary>
            ///  Vérifie que le jeu sélectionné a bien le manuel, la musique et le jeu
            /// </summary>
            bool CheckValidity(string link)
            {
                string tmp;

                tmp = Path.GetFullPath(link, Config.HLaunchBoxPath);
                if (!File.Exists(tmp))
                {
                    return(false);
                }

                return(true);
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicationPath"></param>
        /// <param name="applications"></param>
        /// <returns>Le fichier sélectionné</returns>
        private ICollection <DataPlus> GetFilesForGames(LBGame lbGame)
        {
            List <DataPlus> games = new List <DataPlus>();

            HeTrace.WriteLine($"\t[GetFilesForGames]", this);

            if (string.IsNullOrEmpty(lbGame.ApplicationPath))
            {
                throw new ArgumentNullException("[GetFiles] Folder of application path is empty");
            }

            string extension = Path.GetExtension(lbGame.ApplicationPath);

            // si aucune extension on ne pack pas le fichier
            if (string.IsNullOrEmpty(extension))
            {
                throw new ArgumentNullException("[GetFiles] Extension of application is null");
            }


            // --- Cas des extensions cue
            if (extension.Equals(".cue", StringComparison.OrdinalIgnoreCase))
            {
                string srcFile = Path.GetFullPath(lbGame.ApplicationPath, Common.Config.HLaunchBoxPath);

                //Lecture du fichier cue
                Cue_Scrapper cuecont = new Cue_Scrapper(srcFile);

                //Folder containing files
                string sourceFold = Path.GetDirectoryName(srcFile);

                // Fonctionne avec le nom du fichier
                foreach (string fileName in cuecont.Files)
                {
                    // Donne le lien complet vers le fichier
                    games.Add(DataPlus.MakeNormal(Path.Combine(sourceFold, fileName)));
                }
            }

            games.Add(DataPlus.MakeChosen(lbGame.Id, lbGame.Title, Path.GetFullPath(lbGame.ApplicationPath, Common.Config.HLaunchBoxPath)));


            // ---  Récupération des clones
            List <Clone> clones = XML_Games.ListClones(_XMLPlatformFile, "GameID", lbGame.Id).ToList();

            // tri des doublons / filter duplicates
            List <Clone> fClones = FilesFunc.DistinctClones(clones, lbGame.ApplicationPath, Common.Config.HLaunchBoxPath);


            if (fClones.Any())
            {
                HeTrace.WriteLine($"\t[{nameof(XML_Games.ListClones)}] found: '{fClones.Count()}'", this);

                foreach (Clone c in fClones)
                {
                    string path = Path.GetFullPath(c.ApplicationPath, Common.Config.HLaunchBoxPath);

                    if (File.Exists(path))
                    {
                        games.Add(DataPlus.MakeNormal(c.Id, Path.GetFileName(path), path));
                    }
                }
            }

            return(games);
        }