Beispiel #1
0
        protected bool isHasLocalFile(string httpFullPath)
        {
            if (string.IsNullOrEmpty(httpFullPath))
            {
                return(false);
            }
            string locaPath      = getLocalPathByURL(httpFullPath, true);
            string fullLocalPath = PathDefine.getPersistentLocal(locaPath);

            if (File.Exists(fullLocalPath) == true)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// 取得远程文件在本地的映射路径
        /// </summary>
        /// <param name="url">远程文件路径</param>
        /// <param name="isSubfix">是否只含后缀(不是完整路径)</param>
        /// <returns></returns>
        public string getLocalPathByURL(string url, bool isSubfix = false)
        {
            string localPath = "";
            int    index     = url.IndexOf(PRE_HASH);

            if (index != -1)
            {
                localPath = url.Substring(index + PRE_HASH_LEN);
                localPath = formatedLocalURL(localPath);

                if (isSubfix == false)
                {
                    localPath = PathDefine.getPersistentLocal(localPath);
                }
            }
            return(localPath);
        }
        public RFLoader getLoader(AssetResource resource)
        {
            RFLoader        loader     = null;
            string          url        = resource.url;
            LoaderXDataType parserType = resource.parserType;

            if (_loadingPool.TryGetValue(resource.url, out loader))
            {
                return(loader);
            }

            string locaPath = versionLoaderFactory.getLocalPathByURL(url, true);

            if (resource.isForceRemote == false)
            {
                //先验证是否有热更新的资源
                string fullLocalPath = PathDefine.getPersistentLocal(locaPath);
                if (File.Exists(fullLocalPath) == true)
                {
                    loader = new FileStreamLoader(fullLocalPath, url, parserType);
                }
                else
                {
                    fullLocalPath = PathDefine.getStreamingAssetsLocal(locaPath, true);
                    ///ios强制使用WebRequest;
                    loader = new WebRequestLoader(fullLocalPath, parserType);
                }
            }

            if (loader == null)
            {
                loader             = new WebRequestLoader(url, parserType);
                loader.isLocalFile = false;
                if (resource.isForceRemote)
                {
                    loader.postData = resource.postData;
                    loader.timeout  = resource.timeout;
                }
            }

            _loadingPool[resource.url] = loader;
            return(loader);
        }