Exemple #1
0
        private static void HttpDown_FileNotExit(string httpUrl, Action <string> callback, GameObject sender, string localPath)
        {
            #region 本地文件不存在 开始下载
            //    Debug.Log("Local File Not Exit ");
            HttpProtocolHelper httpLoad = new HttpProtocolHelper();
            httpLoad.m_Url                  = httpUrl;
            httpLoad.m_FilePath             = localPath;
            httpLoad.m_HttpFinishDownHandle = (bool isOK, string _FileName, HttpWebResponse resp) =>
            {
                Loom.QueueOnMainThread(() =>
                {
                    HttpDownLoadCallback(isOK, callback, localPath, httpUrl, resp);
                });
            };
            currentTaskCount++;
            httpLoad.GetHttpFileAndWriteLocalReturnFilePath();  //Begin Get File ,return file path

            #endregion
        }
Exemple #2
0
        private static void CheckWhetherNeedToDown(string localPath, HttpWebResponse response, string _fileRelativeNamePath, string httpUrl, Action <string> callback)
        {
            #region   DownLoadHeadComplete
            FileInfo oldFileInfor = new FileInfo(localPath); //Get the file information ,which contain the length and create time atc.
                                                             //Debug.Log(response.ContentLength + "   Old File Length::" + oldFileInfor.Length);
            if (oldFileInfor.Length != response.ContentLength)
            {                                                //文件长度不一致就下载新的
                #region Local File Is Need Update
                Debug.Log("File Need Update  ::" + _fileRelativeNamePath);
                HttpProtocolHelper httpFile = new HttpProtocolHelper();
                httpFile.m_Url                  = httpUrl;
                httpFile.m_FilePath             = localPath;
                httpFile.m_HttpFinishDownHandle = (bool isOk, string _flle, HttpWebResponse res) =>
                {
                    Loom.QueueOnMainThread(() =>
                    {
                        HttpDownLoadCallback(isOk, callback, localPath, httpUrl, res);
                    });
                };

                httpFile.GetHttpFileAndWriteLocalReturnFilePath();  //Begin Get File ,return file path

                #endregion
            }//if
            else
            {//读取本地文件
                #region GetLocalFile
                //Debug.Log("  The local File is the newest , Get Local File ");

                //if (CacheHelper.GetInstance().CacheImageDic2.ContainsKey(httpUrl) == false)
                //    CacheHelper.GetInstance().CacheImageDic2.Add(httpUrl, localPath); //Save Record

                if (callback != null)
                {
                    callback(localPath);  //return local filepath
                }
                #endregion
            }
            #endregion
        }