private void CopyRoms(string applicationPath, string destLocation) { /* * On part du principe que le dossier rom DOIT être rempli */ if (string.IsNullOrEmpty(applicationPath)) { throw new ArgumentNullException("[CopyRoms] Folder of application path is empty"); } string extension = Path.GetExtension(applicationPath); // si aucune extension on ne pack pas le fichier if (string.IsNullOrEmpty(extension)) { throw new ArgumentNullException("[CopyRoms] Extension of application is null"); } string srcFile = Path.GetFullPath(applicationPath, PS.Default.LBPath); // --- Cas des extensions cue if (extension.Equals(".cue", StringComparison.OrdinalIgnoreCase)) { //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 string source = Path.Combine(sourceFold, fileName); SimpleCopyManager(source, destLocation, ref _FileConflictDecision); } } // --- Copy of application (.cue file too) SimpleCopyManager(srcFile, destLocation, ref _FileConflictDecision); }
/// <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); }
/// <summary> /// Copie les roms, regroupe les fichiers sur les images /// </summary> /// <param name="dbPath"></param> /// <param name="destLocation"></param> /// <returns></returns> private bool CopyRoms(string dbPath, string destLocation) { /* * On part du principe que le dossier rom DOIT être rempli */ if (_zBackGame.ApplicationPath.Length <= 0) { return(false); } string extRom = Path.GetExtension(_zBackGame.ApplicationPath); // si aucune extension on ne pack pas le fichier if (extRom.Length <= 0) { return(false); } try { // résultat pour définir si on copie ou pas EOPResult res; // Traitement dans le cas d'un fichier cue if (extRom.Equals(".cue", StringComparison.OrdinalIgnoreCase)) { //Lecture du fichier cue Cue_Scrapper cuecont = new Cue_Scrapper(_zBackGame.ApplicationPath); //Folder containing files string sourceFold = Path.GetDirectoryName(_zBackGame.ApplicationPath); // Copie de tous les fichiers // Fonctionne avec le nom du fichier foreach (string fileName in cuecont.Files) { // Donne le lien complet vers le fichier string source = Path.Combine(sourceFold, fileName); /*18/10/2020 * // Hardlink * // string destination = Path.Combine(destLocation, fileName); * * * // 2020 Todo * // Test if already copied * * * res = OPFiles.FileNameCompare(source, destLocation, $"Copy_Rom", Dcs_Buttons.NoStop, x => ITrace.WriteLine(x)); * * // Copy * // 2020 * /* * CopyFile(source, destLocation, res); */ /*18 / 10 / 2020 * FilesFunc.Copy(source, Path.Combine(des, res); */ // 18/10/2020 // 2020 remplacement string destFile = Path.Combine(destLocation, fileName); // On fait un prétest pour limiter - Le but est d'évaluer si le fichier de destination existe déjà if (File.Exists(destFile)) //if(fichier.Equals(fichier1)) { /* * * * /* * On teste les fichiers pour voir s'ils sont les mêmes en plus d'avoir le même nom * - Si c'est le cas on va passer, on va passer, puisque l'intégrite est vérifiée * - S'ils sont différents, on va proposer de renommer, passer. * */ // 2020-10-16 //Normalement copy handler doit tout gérer /* Copy_Handler(fichier, destLocation, mediatype); * * * * /* * OPFiles opF = new OPFiles() * { * * }; * opF.IWriteLine += new RetourMessage(x => ITrace.WriteLine(x)); * * // Vérification totale * var res = opF.DeepVerif(fichier, destFile, () => MD5.Create()); * */ //Demande s'il n'y a pas correspondance mais fichiers similaires. //if(res == EFileResult.NoMatch) // test similarity //var res = OPFiles.DeepCompare(fichier, destFile, $"Copy_{mediatype}", () => MD5.Create(), Dcs_Buttons.All, x=> ITrace.WriteLine(x)); } else { FilesFunc.Copy(source, destFile, false); } //2020 } // return true; } // Traitement dans tous les cas (si c'est un cue on en a aussi besoin) /*else * /*{*/ //2020/18/10 res = OPFiles.FileNameCompare(dbPath, destLocation, $"Copy_Rom", Dcs_Buttons.NoStop, x => ITrace.WriteLine(x)); _zBackGame.ApplicationPath = DxPaths.Windows.DxPath.ToRelative(Settings.Default.LBPath, dbPath); //TODO voir peut être si présence avant de copier ? // On copie le fichier donné dans la base // Copy handler ne peut fonctionner que si on lui file un fichier source et un ficher destination à analyser return(Copy_Handler(dbPath, destLocation, "Rom")); /* * return CopyFile(dbPath, destLocation, res); */ //return true; // } } catch (Exception exc) { return(false); } }