public void Cancel() { canceled = true; if (fileStream != null) { fileStream.Close(); fileStream = null; } LoadAndToTemp.RemovePath(originPath); File.Delete(filepath); }
protected override void CompleteContent() { if (Config.Detail_Debug_Log()) { UnityEngine.Debug.LogError("complete content->" + received + "^" + expected); } if (fileStream != null) { LoadAndToTemp.LoadToTempAdditive_End(filepath, fileStream); fileStream = null; } }
private IEnumerator Download() { if (this.wwwStatus == EnumWwwStatus.working) { yield break; } if (www != null) { www.Dispose(); www = null; } this.wwwStatus = EnumWwwStatus.working; { www = UnityWebRequest.Get(this.url); string tempPath = LoadAndToTemp.GenTempPath(); DownloadHandlerFile dhf = new DownloadHandlerFile(tempPath); www.downloadHandler = dhf; yield return(www.SendWebRequest()); if (www.isDone && www.error == null) { _dataPath = tempPath; wwwStatus = EnumWwwStatus.ready; Dispose(); WwwWorkpool.instance.Notify(this, EnumMessageType.DownSuccess); } else if (www.error != null) { Debugger.LogError("download error->" + this.url + "^" + www.error); _dataPath = null; this.wwwStatus = EnumWwwStatus.ready; Dispose(); WwwWorkpool.instance.Notify(this, EnumMessageType.HasError); } else { this.wwwStatus = EnumWwwStatus.ready; _dataPath = null; Dispose(); Debugger.LogError("www download done, but has error->" + www.error); WwwWorkpool.instance.Notify(this, EnumMessageType.HasError); } } }
public FileDownloadHandler(byte[] buffer, string originPath, int originSize, bool removeImpurity) : base(buffer) { if (Config.Detail_Debug_Log()) { UnityEngine.Debug.LogError("file donwload handler init"); } this.originPath = originPath; this.removeImpurity = removeImpurity; this.originSize = originSize; fileStream = LoadAndToTemp.LoadToTempAdditive_Begin(originPath, out filepath); if (Config.Detail_Debug_Log()) { UnityEngine.Debug.LogError("file donwload handler init over->" + filepath); } }
protected override bool ReceiveData(byte[] data, int dataLength) { if (Config.Detail_Debug_Log()) { UnityEngine.Debug.LogError("receive data->" + filepath + "^" + dataLength); } if (expected <= 0) { expected = originSize; } if (data == null || data.Length < 1) { return(false); } received += dataLength; if (!canceled) { LoadAndToTemp.LoadToTempAdditive(filepath, fileStream, data, dataLength, expected, removeImpurity, ref pindex); } return(true); }