示例#1
0
        /// <summary>
        /// Launch zipCompression
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void miZip_Click(object sender, EventArgs e)
        {
            string gameName    = ((ShortGame)lvGames.SelectedItems[0].Tag).FileName.Split('.')[0];
            string folder2Comp = Path.Combine(_OutPPath, PlatformName, gameName);
            string workFolder  = Path.Combine(_OutPPath, PlatformName);

            ZipCompression.Make_Folder(folder2Comp, workFolder, gameName);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        internal bool Run()
        {
            ITrace.WriteLine(prefix: false);

            #region
            // Verifications
            // Todo Verifications with zip and 7z
            //if (Directory.Exists(_GamePath))
            //{


            //}
            #endregion

            /* Déplacé 2020
             * // Creation of System folder and working assign
             * ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_SystemName}'");
             * Directory.CreateDirectory(_SystemName);
             * Directory.SetCurrentDirectory(_SystemPath);
             *
             * // Creation of Game folder
             * ITrace.WriteLine($"[Run] {Lang.CreationFolder}: '{_GamePath}'");
             * Directory.CreateDirectory(_GamePath);
             */
            //2020 Directory.SetCurrentDirectory(_GamePath);


            #region Creation of the Infos.xml
            if (Settings.Default.opInfos)
            {
                MakeXML.InfoGame(_GamePath, _ZeGame);
            }
            else
            {
                ITrace.WriteLine("[Run] Make info disabled");
            }
            #endregion

            // Tree root + lvl1
            MakeStructure();



            // Copy Roms
            #region 22/08/2020 new rom management
            vApps = CopyRoms(_zBackGame.ApplicationPath, _Tree.Children[nameof(SubFolder.Roms)].Path);

            //vApps = CopySpecific(_zBackGame.ApplicationPath, _Tree.Children["Roms"].Path, "Roms", x => _zBackGame.ApplicationPath = x);
            #endregion


            // Video, Music, Manual
            vManual = CopySpecific(_zBackGame.ManualPath, _Tree.Children[nameof(SubFolder.Manuals)].Path, "Manual", x => _zBackGame.ManualPath = x);
            vMusic  = CopySpecific(_zBackGame.MusicPath, _Tree.Children[nameof(SubFolder.Musics)].Path, "Music", x => _zBackGame.MusicPath = x);
            vVideo  = CopySpecific(_zBackGame.VideoPath, _Tree.Children[nameof(SubFolder.Videos)].Path, "Video", x => _zBackGame.VideoPath = x);


            // CopySpecificFiles() old way;

            // Copy images
            CopyImages();

            #region Copy CheatCodes
            if (Settings.Default.opCheatCodes && !string.IsNullOrEmpty(Settings.Default.CCodesPath))
            {
                CopyCheatCodes();
            }
            else
            {
                ITrace.WriteLine("[Run] Copy Cheat Codes disabled");
            }
            #endregion

            #region Copy Clones
            if (Settings.Default.opClones)
            {
                CopyClones();
            }
            else
            {
                ITrace.WriteLine($"[Run] Clone copy disabled");
            }
            #endregion

            #region Serialization / backup ameliorated of launchbox datas (with found medias missing)
            if (Settings.Default.opEBGame)
            {
                MakeXML.Backup_Game(_GamePath, _zBackGame, "EBGame");
            }
            else
            {
                ITrace.WriteLine($"[Run] Enhanced Backup Game disabled");
            }

            #endregion

            #region Save Struct
            if (Settings.Default.opTreeV)
            {
                GetStruc();
            }
            else
            {
                ITrace.WriteLine($"[Run] Save Struct disabled");
            }
            #endregion


            #region 2020 Résultats
            // au lieu de mettre à true le bool au moment de la copie,
            //on fait un recheck au cas où l'utilisateur a modifié le contenu)
            //PackMeRes.ShowDialog(vGame, vManual, vMusic, vVideo, vApps);


            PackMeRes2 pmr2 = new PackMeRes2(_Tree.Path)
            {
                GameName = _zBackGame.Title,
                // Destinations

                /*CheatPath = _Tree.Children[nameof(SubFolder.CheatCodes)].Path,
                 * ManualPath = _Tree.Children[nameof(SubFolder.Manuals)].Path,
                 * MusicPath = _Tree.Children[nameof(SubFolder.Musics)].Path,
                 * RomPath = _Tree.Children[nameof(SubFolder.Roms)].Path,
                 * VideoPath = _Tree.Children[nameof(SubFolder.Videos)].Path,*/
                // Sources
                SourceRomPath    = _ZePlatform.FolderPath,
                SourceManuelPath = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Manual"),
                SourceMusicPath  = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Music"),
                SourceVideoPath  = _ZePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType == "Video"),
            };

            // Liste des manuels

            //pmr2.Musics = Directory.GetFiles(_Tree.Children["Musics"].Path, "*.*", System.IO.SearchOption.TopDirectoryOnly);

            pmr2.LoadDatas();
            pmr2.ShowDialog();


            //pmr2.AddManual();
            #endregion

            #region 2020 choix du nom
            // Fenêtre pour le choix du nom
            GameName gnWindows = new GameName();
            gnWindows.SuggestedGameName = _ZeGame.ExploitableFileName;
            gnWindows.ShowDialog();

            // Changement de nom du dossier
            ushort i = 0;

            string destFolder = Path.Combine(_SystemPath, gnWindows.ChoosenGameName);

            if (!_GamePath.Equals(destFolder))
            {
                while (i < 10)
                {
                    try
                    {
                        Directory.Move(_GamePath, destFolder);
                        ITrace.WriteLine("Folder successfully renamed");

                        // Attribution du résultat
                        _GamePath = destFolder;

                        // Sortie
                        break;
                    }
                    catch (IOException ioe)
                    {
                        ITrace.WriteLine($"Try {i}: {ioe}");
                        Thread.Sleep(10);
                        i++;
                    }
                }
            }

            //string destArchLink = Path.Combine(path, $"{destArchive}");
            //string destArchLink = Path.Combine(path, gnWindows.ChoosenGameName);

            // On verra si on dissocie un jour
            _ZeGame.ExploitableFileName = gnWindows.ChoosenGameName;
            #endregion

            // Archive
            //string destArchive = Path.Combine(_SystemPath, _ZeGame.ExploitableFileName);

            #region Compression
            // Zip
            if (Properties.Settings.Default.opZip)
            {
                //  MessageBox.Show("test "+ destArchive);
                //     Make_Zip(destArchive);
                // ZipCompression.Make_Folder(_GamePath, _SystemPath, destArchive);
                ZipCompression.Make_Folder(_GamePath, _SystemPath, _ZeGame.ExploitableFileName);
            }
            else
            {
                ITrace.WriteLine($"[Run] Zip Compression disabled");
            }
            // 7-Zip
            if (Properties.Settings.Default.op7_Zip)
            {
                //MessageBox.Show("test " + destArchive);

                // SevenZipCompression.Make_Folder(_GamePath, _SystemPath, destArchive);
                SevenZipCompression.Make_Folder(_GamePath, _SystemPath, _ZeGame.ExploitableFileName);
            }
            else
            {
                ITrace.WriteLine($"[Run] 7z Compression disabled");
            }
            #endregion

            // Erase the temp folder
            if (MessageBox.Show($"{Lang.EraseTmpFolder} '{_ZeGame.ExploitableFileName}' ?", Lang.Erase, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    Directory.SetCurrentDirectory(_WFolder);
                    Directory.Delete(_GamePath, true);
                    Console.WriteLine($"[Run] folder {_GamePath} erased");
                }
                catch (Exception exc)
                {
                    Console.WriteLine($"[Run] Error when Erasing temp folder {_GamePath}\n{exc.Message }");
                }
            }


            // Stop loggers
            if (_IScreen != null)
            {
                _IScreen.KillAfter(10);
            }

            ITrace.RemoveListerners(_Loggers);

            return(true);
        }