Esempio n. 1
0
        private void CopyImages(List <DataRepExt> images, string destLocation)
        {
            E_Decision resMem = E_Decision.None;
            string     tail, futurLink;

            foreach (DataRepExt pkFile in images)
            {
                tail = string.Empty;
                // On récupère la tail
                PlatformFolder folder = _ZePlatform.PlatformFolders.First(
                    (x) => x.MediaType.Equals(pkFile.Categorie, StringComparison.OrdinalIgnoreCase));


                if (folder != null && pkFile.ALinkToThePath.Contains(folder.FolderPath))
                {
                    tail = pkFile.ALinkToThePath.Replace(folder.FolderPath, string.Empty).TrimStart('\\');

                    futurLink = Path.Combine(destLocation, pkFile.Categorie, tail);
                }
                else
                {
                    futurLink = Path.Combine(destLocation, Path.GetFileName(pkFile.ALinkToThePath));
                }

                SimpleCopyManager(pkFile.ALinkToThePath, ref resMem, futurLink);

                // Dossier de destination
                //25/03/2021string destFolder = Path.Combine(_Tree.Children[nameof(SubFolder.Images)].Path, tail1);
                //string destFolder = Path.Combine(imgsFolder, tail1);

                //SimpleCopyManager(pkFile.LinkToThePath, destFolder, ref resMem);
            }
        }
Esempio n. 2
0
        /*   /// <summary>
         * ///
         * /// </summary>
         * /// <param name="path"></param>
         * /// <param name="compApps"></param>
         * /// <param name="destLocation"></param>
         * /// <returns></returns>
         * /// <remarks>
         * /// On ne garde pas le tail
         * /// </remarks>
         * private string CopyMain(string path, string destLocation)
         * {
         * string futurLink = Path.Combine(destLocation, Path.GetFileName(path));
         *
         * SimpleCopyManager(path, ref _FileConflictDecision, futurLink);
         *
         * return DxPath.To_Relative(destLocation, futurLink);
         * }*/

        private string CopyMain(string fichier, string destLocation, bool wTail, string mediatype = null)
        {
            if (string.IsNullOrEmpty(fichier))
            {
                return(string.Empty);
            }

            PlatformFolder folder = null;

            if (wTail && !string.IsNullOrEmpty(mediatype))
            {
                // On récupère le dossier concerné par le média
                folder = _ZePlatform.PlatformFolders.First(
                    (x) => x.MediaType.Equals(mediatype, StringComparison.OrdinalIgnoreCase));
            }

            string futurLink, tail;

            futurLink = tail = string.Empty;

            if (folder != null && fichier.Contains(folder.FolderPath))
            {
                tail      = fichier.Replace(folder.FolderPath, string.Empty).TrimStart('\\');
                futurLink = Path.Combine(destLocation, tail);
            }
            else
            {
                futurLink = Path.Combine(destLocation, Path.GetFileName(fichier));
            }

            SimpleCopyManager(fichier, ref _FileConflictDecision, futurLink);

            return(DxPath.To_Relative(destLocation, futurLink));
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="compApps"></param>
        /// <param name="folder"></param>
        /// <remarks>
        /// Conserve la structure si c'est souhaité
        /// </remarks>
        private void CopyList(List <string> elems, string destLocation, bool wTail, string mediatype = null)
        {
            PlatformFolder folder = null;

            if (wTail && !string.IsNullOrEmpty(mediatype))
            {
                // On récupère le dossier concerné par le média
                folder = _ZePlatform.PlatformFolders.First(
                    (x) => x.MediaType.Equals(mediatype, StringComparison.OrdinalIgnoreCase));
            }

            string tail, futurLink;

            foreach (string fichier in elems)
            {
                futurLink = string.Empty;
                tail      = string.Empty;

                if (wTail)
                {
                    if (folder != null && fichier.Contains(folder.FolderPath))
                    {
                        tail      = fichier.Replace(folder.FolderPath, string.Empty).TrimStart('\\');
                        futurLink = Path.Combine(destLocation, tail);

                        SimpleCopyManager(fichier, ref _FileConflictDecision, futurLink);
                        continue;
                    }
                }

                futurLink = Path.Combine(destLocation, Path.GetFileName(fichier));
                SimpleCopyManager(fichier, ref _FileConflictDecision, futurLink);
            }
        }
Esempio n. 4
0
        private void PrepareImages(List <DataRepImg> images, string destLocation)
        {
            E_Decision resMem = E_Decision.None;
            string     tail;

            foreach (DataRepImg pkFile in images)
            {
                tail = string.Empty;
                // On récupère la tail
                PlatformFolder pFolder = _ZePlatform.PlatformFolders.First(
                    (x) => x.MediaType.Equals(pkFile.Categorie, StringComparison.OrdinalIgnoreCase));

                string toReplace = Path.GetFullPath(pFolder.FolderPath, Common.Config.HLaunchBoxPath);
                if (toReplace != null && pkFile.CurrentPath.Contains(toReplace))
                {
                    tail = pkFile.CurrentPath.Replace(toReplace, string.Empty).TrimStart('\\');

                    pkFile.DestPath = Path.Combine(destLocation, pkFile.Categorie, tail);
                }
                else
                {
                    pkFile.DestPath = Path.Combine(destLocation, Path.GetFileName(pkFile.CurrentPath));
                }
            }
        }
Esempio n. 5
0
        internal void CopyMusicF()
        {
            PlatformFolder pFolder = Platform.PlatformFolders.FirstOrDefault((x) => x.MediaType == "Music");
            string         folder  = pFolder == null ? string.Empty : pFolder.FolderPath;

            if (Copy2(folder, Common.Musics, "Select a music file", MusicsCollection))
            {
                LoadMusics();
            }
        }
Esempio n. 6
0
        internal void CopyVideoF()
        {
            PlatformFolder pFolder = Platform.PlatformFolders.FirstOrDefault((x) => x.MediaType == "Video");
            string         folder  = pFolder == null ? string.Empty : pFolder.FolderPath;

            if (Copy2(folder, Common.Videos, "Select a video file", VideosCollection))
            {
                LoadVideos();
            }
        }
Esempio n. 7
0
        /*
         * /// <summary>
         * /// Fonction de copie des fichiers
         * /// </summary>
         * /// <param name="sourceDirectory">Répertoire source</param>
         * /// <param name="targetDirectory">Répertoire cible</param>
         * public void CopyGameF()
         * {
         *  if (Copy2(Platform.FolderPath, Common.Games, "Select a game file", GamesCollection))
         *  {
         *      LoadGames();
         *  }
         * }*/
        /*
         * internal void RemoveGameF()
         * {
         *  if (SelectedGame.IsSelected)
         *  {
         *      DxMBox.ShowDial("You must select another before to delete it");
         *      return;
         *  }
         *
         *  if (SelectedGame != null)
         *  {
         *
         *      OpDFiles.Trash(SelectedGame.DestPath);
         *      LoadGames();
         *  }
         *  /*  if (SelectedGame != null)
         *    {
         *        OpDFiles.Trash(SelectedGame.ALinkToThePath);
         *        LoadGames();
         *    }*//*
         * }
         */

        #region Manuals

        internal void CopyManualF()
        {
            PlatformFolder pFolder = Platform.PlatformFolders.FirstOrDefault((x) => x.MediaType == "Manual");
            string         folder  = pFolder == null ? string.Empty : pFolder.FolderPath;

            if (Copy2(folder, Common.Manuals, "Select a manual", ManualsCollection))
            {
                LoadManuals();
            }
        }
        /// <summary>
        /// Create or get the path to a special folder for a platform
        /// </summary>
        /// <param name="ns">Game namespace</param>
        /// <param name="platform">Platform folder</param>
        /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
        /// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
        /// <returns>Path to the folder</returns>
        public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, bool create)
        {
            string dir_path = string.Format("{0}{1}\\", CreatePlatform(ns, platform), folder.ToString().Replace('_', '\\'));

            if (create && !Directory.Exists(dir_path))
            {
                Directory.CreateDirectory(dir_path);
            }

            return(dir_path);
        }
        /// <summary>
        /// Create or get the path to a file
        /// </summary>
        /// <param name="ns">Game namespace</param>
        /// <param name="platform">Platform folder</param>
        /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
        /// <param name="file">File name</param>
        /// <param name="ext">File extension</param>
        /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
        /// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
        /// <returns>Path to the file</returns>
        public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides, bool create)
        {
            string file_path = string.Format("{0}{1}.{2}", CreatePlatformFolder(ns, platform, folder, overrides), file, ext);

            if (create && !File.Exists(file_path))
            {
                File.Create(file_path).Close();
            }

            return(file_path);
        }
        /// <summary>
        /// Get the relative path to a special folder for a platform
        /// </summary>
        /// <param name="ns">Game namespace</param>
        /// <param name="platform">Platform folder</param>
        /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
        /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
        /// <returns>Relative path to the folder</returns>
        public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides)
        {
            string dir_path;

            if (overrides != null && overrides.GetOverride(folder, out dir_path))
            {
                return(dir_path);
            }
            else
            {
                return(GetRelativePath(ns, platform, folder));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Interface avec predict pour récupérer le bon dossier
        /// </summary>
        /// <param name="mediatype"></param>
        /// <param name="titleElements"></param>
        /// <returns></returns>
        private List <string> GetMoreFiles(string mediatype, Dictionary <string, string> titleElements /*, params string[] fields*/)
        {
            // On récupère le dossier concerné par le média
            PlatformFolder folder = _ZePlatform.PlatformFolders.FirstOrDefault(
                (x) => x.MediaType.Equals(mediatype, StringComparison.OrdinalIgnoreCase));

            if (folder == null)
            {
                return(null);
            }

            //List<string> filteredFiles = GetFilesByPredict(toSearch, folder.FolderPath, mediatype);
            return(GetFilesByPredict(titleElements, folder.FolderPath, mediatype));
        }
Esempio n. 12
0
    private IPlatformFolder CreateAndValidateApplicationFolder(string path)
    {
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        IPlatformFolder result             = null;
        var             telemetryDirectory = new DirectoryInfo(path);

        TelemetryChannelEventSource.Log.StorageFolder(telemetryDirectory.FullName);
        result = new PlatformFolder(telemetryDirectory);
        return(result);
    }
Esempio n. 13
0
			/// <summary>
			/// Get the path that overrides <paramref name="pf"/>
			/// </summary>
			/// <param name="pf">The platform's folder. Must only have one folder flag set.</param>
			/// <param name="override_path">The overridden path value</param>
			/// <returns>True if a override exists</returns>
			public bool GetOverride(PlatformFolder pf, out string override_path)
			{
				override_path = null;

				switch(pf)
				{
					case PlatformFolder.Tags: override_path = tags; break;
					case PlatformFolder.Data: override_path = data; break;
					case PlatformFolder.Maps: override_path = maps; break;
					case PlatformFolder.Plugins: override_path = plugins; break;
					default: return false;
				}
				if (override_path == null) return false; // the override path wasn't defined in the first place
				return true;
			}
Esempio n. 14
0
        private void PrepareList <T>(IEnumerable <T> elems, Folder tree, bool keepStruct, string mediatype) where T : DataTrans
        {
            HeTrace.WriteLine($"[{nameof(PrepareList)}] for {mediatype}", this);
            string destLocation = tree.Children[$"{mediatype}s"].Path;


            // protection
            if (mediatype == "CheatCode" && string.IsNullOrEmpty(Config.HCCodesPath))
            {
                return;
            }



            string folder = null;

            //PlatformFolder folder = null;
            if (mediatype == "Game")
            {
                folder = _ZePlatform.FolderPath ??= Path.Combine("Games", _ZePlatform.Name);
            }
            else if (mediatype == "CheatCode")
            {
                folder = Path.Combine(Config.HCCodesPath, _ZePlatform.Name);
            }
            else if (!string.IsNullOrEmpty(mediatype))
            {
                // On récupère le dossier concerné par le média
                PlatformFolder pFolder = _ZePlatform.PlatformFolders.FirstOrDefault(
                    (x) => x.MediaType.Equals(mediatype, StringComparison.OrdinalIgnoreCase));

                folder = pFolder.FolderPath;
            }

            if (folder.Equals(Config.HLaunchBoxPath) || folder.Equals(AppDomain.CurrentDomain.BaseDirectory))
            {
                throw new Exception($"Error on target folder '{folder}'");
            }


            folder = Path.GetFullPath(folder, Config.HLaunchBoxPath);
            foreach (var fichier in elems)
            {
                PrepareFile(fichier, destLocation, keepStruct, folder);
            }
        }
        /// <summary>
        /// Create or get the path to a special folder for a platform
        /// </summary>
        /// <param name="ns">Game namespace</param>
        /// <param name="platform">Platform folder</param>
        /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
        /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
        /// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
        /// <returns>Path to the folder</returns>
        public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides, bool create)
        {
            string dir_path;

            if (overrides != null && overrides.GetOverride(folder, out dir_path))
            {
                if (create && !Directory.Exists(dir_path))
                {
                    Directory.CreateDirectory(dir_path);
                }

                return(dir_path);
            }
            else
            {
                return(CreatePlatformFolder(ns, platform, folder));
            }
        }
        /// <summary>
        /// Checks to see if there are multiple folder flags
        /// </summary>
        /// <param name="folder">Platform's folder. Can have more than one folder flag set.</param>
        /// <returns>true if there are multiple folder flags</returns>
        private static bool CheckPlatformFolderFlags(PlatformFolder folder)
        {
            int  f        = (int)folder;
            bool _checked = false;

            for (int x = 0; x < sizeof(PlatformFolder) * 8; x++)
            {
                if ((f & x) != 0)
                {
                    if (_checked)
                    {
                        return(true);
                    }
                    else
                    {
                        _checked = true;
                    }
                }
            }
            return(false);
        }
            /// <summary>
            /// Get the path that overrides <paramref name="pf"/>
            /// </summary>
            /// <param name="pf">The platform's folder. Must only have one folder flag set.</param>
            /// <param name="override_path">The overridden path value</param>
            /// <returns>True if a override exists</returns>
            public bool GetOverride(PlatformFolder pf, out string override_path)
            {
                override_path = null;

                switch (pf)
                {
                case PlatformFolder.Tags: override_path = tags; break;

                case PlatformFolder.Data: override_path = data; break;

                case PlatformFolder.Maps: override_path = maps; break;

                case PlatformFolder.Plugins: override_path = plugins; break;

                default: return(false);
                }
                if (override_path == null)
                {
                    return(false);                                       // the override path wasn't defined in the first place
                }
                return(true);
            }
Esempio n. 18
0
			/// <summary>
			/// Create or get the path to a file
			/// </summary>
			/// <param name="ns">Game namespace</param>
			/// <param name="platform">Platform folder</param>
			/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
			/// <param name="file">File name</param>
			/// <param name="ext">File extension</param>
			/// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
			/// <returns>Path to the file</returns>
			public string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, bool create)	{ return GameManager.CreatePlatformFile(ns, platform, folder, file, ext, this, create); }
Esempio n. 19
0
			/// <summary>
			/// Get the relative path to a file
			/// </summary>
			/// <param name="ns">Game namespace</param>
			/// <param name="platform">Platform folder</param>
			/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
			/// <param name="file">File name</param>
			/// <param name="ext">File extension</param>
			/// <returns>Relative path to the file</returns>
			public string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext)					{ return GameManager.GetRelativePath(ns, platform, folder, file, ext, this); }
 /// <summary>
 /// Get the relative path to a file
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <param name="file">File name</param>
 /// <param name="ext">File extension</param>
 /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
 /// <returns>Relative path to the file</returns>
 public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides)
 {
     return(string.Format("{0}{1}.{2}", GetRelativePath(ns, platform, folder, overrides), file, ext));
 }
Esempio n. 21
0
		/// <summary>
		/// Create or get the path to a file
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="file">File name</param>
		/// <param name="ext">File extension</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
		/// <returns>Path to the file</returns>
		public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides, bool create)
		{
			string file_path = string.Format("{0}{1}.{2}", CreatePlatformFolder(ns, platform, folder, overrides), file, ext);

			if (create && !File.Exists(file_path)) File.Create(file_path).Close();

			return file_path;
		}
Esempio n. 22
0
		/// <summary>
		/// Get the relative path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <returns>Relative path to the folder</returns>
		public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder) { return string.Format("{0}{1}\\", GetRelativePath(ns, platform), folder.ToString().Replace('_', '\\')); }
Esempio n. 23
0
		/// <summary>
		/// Create or get the path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <returns>Path to the folder</returns>
		public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder) { return CreatePlatformFolder(ns, platform, folder, true); }
 /// <summary>
 /// Get the relative path to a special folder for a platform
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <returns>Relative path to the folder</returns>
 public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder)
 {
     return(string.Format("{0}{1}\\", GetRelativePath(ns, platform), folder.ToString().Replace('_', '\\')));
 }
 /// <summary>
 /// Gets a complete platform folder path based on a game's namespace, and its platform
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <returns></returns>
 public static string GetPlatformFolderPath(Namespace ns, Platform platform, PlatformFolder folder)
 {
     return(string.Format("{0}{1}\\{2}\\{3}\\", Program.GamesPath, ns.ToString(), platform.ToString(), folder.ToString().Replace('_', '\\')));
 }
 /// <summary>
 /// Create or get the path to a special folder for a platform
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <returns>Path to the folder</returns>
 public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder)
 {
     return(CreatePlatformFolder(ns, platform, folder, true));
 }
 /// <summary>
 /// Get the relative path to a file
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <param name="file">File name</param>
 /// <param name="ext">File extension</param>
 /// <returns>Relative path to the file</returns>
 public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext)
 {
     return(string.Format("{0}{1}.{2}", CreatePlatformFolder(ns, platform, folder), file, ext));
 }
 /// <summary>
 /// Create or get the path to a file
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <param name="file">File name</param>
 /// <returns>Path to the file</returns>
 public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file)
 {
     return(CreatePlatformFile(ns, platform, folder, file, true));
 }
Esempio n. 29
0
        private void CopySpecific(string toSearch, string dbGamePath, string destLocation, string mediatype, Func <string, string> Assignation)
        {
            List <string> files = new List <string>();

            // Normal copy, if path get by xml exists
            // 05/04/2021 Modifications pour lever le ou et mettre un système de "Et"
            if (!string.IsNullOrEmpty(dbGamePath))
            {
                string linkFile = Path.GetFullPath(dbGamePath, PS.Default.LBPath);
                if (File.Exists(linkFile))
                {
                    //05/04/2021 SimpleCopyManager(dbPath, destLocation/*, mediatype*/, ref _FileConflictDecision);
                    files.Add(linkFile);
                }

                // Ici on met sous forme relative
                // Assignation(DxPaths.Windows.DxPath.To_Relative(PS.Default.LBPath, linkFile));
            }



            // On récupère le dossier concerné par le média
            PlatformFolder folder = _ZePlatform.PlatformFolders.First(
                (x) => x.MediaType.Equals(mediatype, StringComparison.OrdinalIgnoreCase));

            /*foreach (PlatformFolder pFormfolder in _ZePlatform.PlatformFolders)
             * {
             *  if (pFormfolder.MediaType.Equals(mediatype))
             *  {
             *      folder = pFormfolder;
             *      break;
             *  }
             * }*/

            List <string> filteredFiles = GetFilesByPredict(toSearch, folder.FolderPath, mediatype);


            // En cas d'abandon ou de fichier non trouvé on sort
            if (files.Count == 0 && (filteredFiles == null || filteredFiles.Count == 0))
            {
                return;
            }

            // On assigne si nécessaire

            /*  if (files.Count == 0 && filteredFiles.Count > 0)
             *    Assignation(DxPaths.Windows.DxPath.To_Relative(PS.Default.LBPath, filteredFiles[0]));*/


            files.AddRange(filteredFiles);

            // On enlève les doublons
            files = files.Distinct().ToList();

            #region
            // Traitement des fichiers pour la copie
            foreach (string fichier in filteredFiles)
            {
                // Sachant qu'ici on a le nom du dossier source on peut conserver la structure
                string tail = string.Empty;

                if (fichier.Contains(folder.FolderPath))
                {
                    tail = fichier.Replace(folder.FolderPath, "").Replace(Path.GetFileName(fichier), "");
                }

                //Recherche de fichiers déjà présents
                //string destFile = Path.Combine(destLocation, Path.GetFileName(fichier));

                if (string.IsNullOrEmpty(tail))
                {
                    SimpleCopyManager(fichier, destLocation, ref _FileConflictDecision);
                }
                else
                {
                    SimpleCopyManager(fichier, Path.Combine(destLocation, tail.Substring(1)), ref _FileConflictDecision);
                }
            }


            #endregion
        }
Esempio n. 30
0
        private void AssignTargets(GameDataCont gdC, string root, ContPlatFolders zePlatform)
        {
            string platFolderPath = zePlatform.FolderPath;

            if (string.IsNullOrEmpty(platFolderPath))
            {
                platFolderPath = Path.Combine(Config.HLaunchBoxPath, "Games");
            }
            else
            {
                platFolderPath = Path.GetFullPath(platFolderPath, Config.HLaunchBoxPath);
            }

            string appTarget = string.Empty;

            if (Config.UseGameNameFolder)
            {
                appTarget = Path.Combine(platFolderPath, Tool.WindowsConv_TitleToFileName(gdC.Title));
            }
            else
            {
                appTarget = platFolderPath;
            }

            // Games
            foreach (var app in gdC.Applications)
            {
                app.DestPath = app.CurrentPath.Replace(Path.Combine(root, Config.Games), appTarget);
            }

            AssignTarget(gdC.Manuals, root, Config.Manuals, Tag.MediaTManual, zePlatform);
            AssignTarget(gdC.Musics, root, Config.Musics, Tag.MediaTMusic, zePlatform);
            AssignTarget(gdC.Videos, root, Config.Videos, Tag.MediaTVideo, zePlatform);

            //    string destPath = zePlatform.PlatformFolders.FirstOrDefault((x => x.MediaType.Equals(mediatype))).FolderPath;

            AssignImages(gdC.Images, root, zePlatform);


            void AssignTarget(IEnumerable <DataRep> elems, string root, string subFolder, string mediaType, ContPlatFolders zePlatform)
            {
                var    dFolder    = zePlatform.PlatformFolders.First(x => x.MediaType.Equals(mediaType));
                string destFolder = Path.GetFullPath(dFolder.FolderPath, Config.HLaunchBoxPath);

                string src = Path.Combine(root, subFolder);

                foreach (var e in elems)
                {
                    e.DestPath = e.CurrentPath.Replace(src, destFolder);
                }
            }

            void AssignImages(List <DataRepImg> images, string root, ContPlatFolders zePlatform)
            {
                string prevMedType = string.Empty;
                string toReplace   = string.Empty;
                string target      = string.Empty;

                foreach (DataRepImg image in images)
                {
                    if (!prevMedType.Equals(image.Categorie))
                    {
                        prevMedType = image.Categorie;
                        toReplace   = Path.Combine(root, Config.Images, image.Categorie);

                        PlatformFolder pTarget = zePlatform.PlatformFolders.FirstOrDefault(x => x.MediaType.Equals(image.Categorie));
                        target = Path.GetFullPath(pTarget.FolderPath, Config.HLaunchBoxPath);
                    }

                    image.DestPath = image.CurrentPath.Replace(toReplace, target);
                }
            }
        }
Esempio n. 31
0
		/// <summary>
		/// Checks to see if there are multiple folder flags
		/// </summary>
		/// <param name="folder">Platform's folder. Can have more than one folder flag set.</param>
		/// <returns>true if there are multiple folder flags</returns>
		private static bool CheckPlatformFolderFlags(PlatformFolder folder)
		{
			int f = (int)folder;
			bool _checked = false;
			for (int x = 0; x < sizeof(PlatformFolder) * 8; x++)
			{
				if ((f & x) != 0)
					if (_checked)	return true;
					else			_checked = true;
			}
			return false;
		}
Esempio n. 32
0
		/// <summary>
		/// Create or get the path to a file
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="file">File name</param>
		/// <returns>Path to the file</returns>
		public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file) { return CreatePlatformFile(ns, platform, folder, file, true); }
Esempio n. 33
0
		/// <summary>
		/// Gets a complete platform folder path based on a game's namespace, and its platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <returns></returns>
		public static string GetPlatformFolderPath(Namespace ns, Platform platform, PlatformFolder folder)
		{
			return string.Format("{0}{1}\\{2}\\{3}\\", Program.GamesPath, ns.ToString(), platform.ToString(), folder.ToString().Replace('_', '\\'));
		}
Esempio n. 34
0
		/// <summary>
		/// Get the relative path to a file
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="file">File name</param>
		/// <param name="ext">File extension</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <returns>Relative path to the file</returns>
		public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides)
		{
			return string.Format("{0}{1}.{2}", GetRelativePath(ns, platform, folder, overrides), file, ext);
		}
Esempio n. 35
0
		/// <summary>
		/// Get the relative path to a file
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="file">File name</param>
		/// <param name="ext">File extension</param>
		/// <returns>Relative path to the file</returns>
		public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext) { return string.Format("{0}{1}.{2}", CreatePlatformFolder(ns, platform, folder), file, ext); }
Esempio n. 36
0
		/// <summary>
		/// Create or get the path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
		/// <returns>Path to the folder</returns>
		public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides, bool create)
		{
			string dir_path;
			if (overrides != null && overrides.GetOverride(folder, out dir_path))
			{
				if (create && !Directory.Exists(dir_path)) Directory.CreateDirectory(dir_path);

				return dir_path;
			}
			else
				return CreatePlatformFolder(ns, platform, folder);
		}
Esempio n. 37
0
		/// <summary>
		/// Create or get the path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
		/// <returns>Path to the folder</returns>
		public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, bool create)
		{
			string dir_path = string.Format("{0}{1}\\", CreatePlatform(ns, platform), folder.ToString().Replace('_', '\\'));

			if (create && !Directory.Exists(dir_path)) Directory.CreateDirectory(dir_path);

			return dir_path;
		}
 /// <summary>
 /// Create or get the path to a special folder for a platform
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
 /// <returns>Path to the folder</returns>
 public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides)
 {
     return(CreatePlatformFolder(ns, platform, folder, overrides, true));
 }
Esempio n. 39
0
		/// <summary>
		/// Get the relative path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <returns>Relative path to the folder</returns>
		public static string GetRelativePath(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides)
		{
			string dir_path;
			if (overrides != null && overrides.GetOverride(folder, out dir_path))
				return dir_path;
			else
				return GetRelativePath(ns, platform, folder);
		}
Esempio n. 40
0
        /// <summary>
        /// Convert a platform in object (partiel)
        /// </summary>
        /// <param name="Name"></param>
        /// <returns></returns>
        internal Platform ScrapPlatform(string Name)
        {
            Platform zePlatform = new Platform();

            zePlatform.Name = Name;


            XPathNavigator nav = _XDoc.CreateNavigator();

            // Infos
            XPathNodeIterator nodInfos = nav.Select(nav.Compile($"//LaunchBox/Platform[Name='{Name}']"));

            if (nodInfos.Count != 0)
            {
                nodInfos.MoveNext();
                nodInfos.Current.MoveToFirstChild();
                do
                {
                    switch (nodInfos.Current.Name)
                    {
                    // Correction sur le xml originel
                    case "Folder":
                        /*2020 n'était jamais utilisé, une erreur en prime car pas ajouté à la liste
                         * PlatformFolder pfFolder = new PlatformFolder();
                         * pfFolder.FolderPath = nodInfos.Current.Value;
                         * pfFolder.MediaType = "AppPath";*/
                        zePlatform.FolderPath = nodInfos.Current.Value;
                        break;
                    }
                } while (nodInfos.Current.MoveToNext());
            }

            // Get path
            XPathNodeIterator nodPaths = nav.Select(nav.Compile($"//LaunchBox/PlatformFolder[Platform='{Name}']"));

            if (nodPaths.Count != 0)
            {
                while (nodPaths.MoveNext())
                {
                    //Console.WriteLine(nodIImages.Current.Name);
                    nodPaths.Current.MoveToFirstChild();
                    PlatformFolder pfFolder = new PlatformFolder();

                    do
                    {
                        //Console.WriteLine($"\t{nodIImages.Current.Name} = {nodIImages.Current.Value}");

                        switch (nodPaths.Current.Name)
                        {
                        case "MediaType":
                            pfFolder.MediaType = nodPaths.Current.Value;
                            break;

                        case "FolderPath":
                            pfFolder.FolderPath = nodPaths.Current.Value;
                            break;
                        }
                    } while (nodPaths.Current.MoveToNext());

                    zePlatform.PlatformFolders.Add(pfFolder);
                }


                //nodIImages.MoveNext();
            }



            return(zePlatform);
        }
Esempio n. 41
0
		/// <summary>
		/// Create or get the path to a special folder for a platform
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <returns>Path to the folder</returns>
		public static string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, Overrides overrides) { return CreatePlatformFolder(ns, platform, folder, overrides, true); }
Esempio n. 42
0
        private void UploadFileToGroup()
        {
            var folder = new PlatformFolder(User.Session, User, Group.FolderUuid);

            if (_fileModel.GroupUuid == Group.Uuid)
            {
                var fileId = OfficePropertiesInterop.GetProperty(_fileModel.FullPath, "WorkshareFileId");
                var version = WorkshareOnline.Instance.FileTransfer.UploadNewVersion2(_fileModel.FullPath, Convert.ToInt32(fileId),
                    Group.Uuid);

                _fileModel.FileId = version.Item1.FileId.ToString();
                _file = version.Item2;
                _file.VersionId = (int)version.Item1.Id;
                Link = WorkshareOnline.Instance.Groups.Invite(version.Item1.Password, Group.Uuid);

                if (_fileModel.DisplayName != _fileModel.FileName)
                    version.Item2.Rename(_fileModel.DisplayName);
            }
            else
            {
                _file = WorkshareOnline.Instance.FileTransfer.Upload(_fileModel.FullPath, _fileModel.DisplayName, folder, Group.Uuid);
                _fileModel.FileId = _file.Id.ToString();
                Link = WorkshareOnline.Instance.Groups.Invite(_file.Password, Group.Uuid);
            }
            
            _fileModel.GroupUuid = Group.Uuid;
        }
Esempio n. 43
0
		/// <summary>
		/// Create or get the path to a file
		/// </summary>
		/// <param name="ns">Game namespace</param>
		/// <param name="platform">Platform folder</param>
		/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
		/// <param name="file">File name</param>
		/// <param name="ext">File extension</param>
		/// <param name="overrides">Optional set of overrides to use. Can be null.</param>
		/// <returns>Path to the file</returns>
		public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides) { return CreatePlatformFile(ns, platform, folder, file, ext, overrides, true); }
Esempio n. 44
0
			/// <summary>
			/// Create or get the path to a special folder for a platform
			/// </summary>
			/// <param name="ns">Game namespace</param>
			/// <param name="platform">Platform folder</param>
			/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
			/// <param name="create">True if we should create the path on disk if it doesn't exist already</param>
			/// <returns>Path to the folder</returns>
			public string CreatePlatformFolder(Namespace ns, Platform platform, PlatformFolder folder, bool create)							{ return GameManager.CreatePlatformFolder(ns, platform, folder, this, create); }
Esempio n. 45
0
			/// <summary>
			/// Create or get the path to a file
			/// </summary>
			/// <param name="ns">Game namespace</param>
			/// <param name="platform">Platform folder</param>
			/// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
			/// <param name="file">File name</param>
			/// <returns>Path to the file</returns>
			public string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file)							{ return GameManager.CreatePlatformFile(ns, platform, folder, file, this); }
 /// <summary>
 /// Create or get the path to a file
 /// </summary>
 /// <param name="ns">Game namespace</param>
 /// <param name="platform">Platform folder</param>
 /// <param name="folder">Platform's folder. Must only have one folder flag set.</param>
 /// <param name="file">File name</param>
 /// <param name="ext">File extension</param>
 /// <param name="overrides">Optional set of overrides to use. Can be null.</param>
 /// <returns>Path to the file</returns>
 public static string CreatePlatformFile(Namespace ns, Platform platform, PlatformFolder folder, string file, string ext, Overrides overrides)
 {
     return(CreatePlatformFile(ns, platform, folder, file, ext, overrides, true));
 }