Example #1
0
        /// <summary>
        /// 获取Lib下载任务
        /// </summary>
        /// <param name="source">下载源</param>
        /// <param name="lib">lib实例</param>
        /// <param name="core">所使用的核心</param>
        /// <returns>下载任务</returns>
        public static DownloadTask GetLibDownloadTask(DownloadSource source, Modules.Library lib, LaunchHandler core)
        {
            string from = GetLibDownloadURL(source, lib);
            string to   = core.GetLibraryPath(lib);

            return(new DownloadTask("版本依赖库文件" + lib.Name, from, to));
        }
 /// <summary>
 /// 获取版本是否丢失任何库文件
 /// </summary>
 /// <param name="core">启动核心</param>
 /// <param name="version">检查的版本</param>
 /// <returns>是否丢失任何库文件</returns>
 public static bool IsLostAnyLibs(LaunchHandler core, Version version)
 {
     foreach (var item in version.Libraries)
     {
         string path = core.GetLibraryPath(item);
         if (!File.Exists(path))
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// 获取版本丢失的库文件
        /// </summary>
        /// <param name="core">所使用的启动核心</param>
        /// <param name="version">要检查的版本</param>
        /// <returns>返回Key为路径,value为库实例的集合</returns>
        public static Dictionary <string, Modules.Library> GetLostLibs(LaunchHandler core, Version version)
        {
            Dictionary <string, Modules.Library> lostLibs = new Dictionary <string, Modules.Library>();

            foreach (var item in version.Libraries)
            {
                string path = core.GetLibraryPath(item);
                if (lostLibs.ContainsKey(path))
                {
                    continue;
                }
                else if (!File.Exists(path))
                {
                    lostLibs.Add(path, item);
                }
            }
            return(lostLibs);
        }