mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update LoaderUtilities.cs
This commit is contained in:
@@ -12,7 +12,6 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
public class LoaderUtilities
|
public class LoaderUtilities
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取文件的md5码
|
/// 获取文件的md5码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -25,6 +24,7 @@ namespace TEngine.Runtime
|
|||||||
TLogger.LogWarning($"not exit file,path:{fileName}");
|
TLogger.LogWarning($"not exit file,path:{fileName}");
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
@@ -36,9 +36,9 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
sb.Append(retVal[i].ToString("x2"));
|
sb.Append(retVal[i].ToString("x2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -133,6 +133,7 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
MonoUtility.StopCoroutine(_coroutine);
|
MonoUtility.StopCoroutine(_coroutine);
|
||||||
}
|
}
|
||||||
|
|
||||||
_coroutine = MonoUtility.StartCoroutine(_Response(_msgContent));
|
_coroutine = MonoUtility.StartCoroutine(_Response(_msgContent));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +172,8 @@ namespace TEngine.Runtime
|
|||||||
stream.Close();
|
stream.Close();
|
||||||
stream.Dispose();
|
stream.Dispose();
|
||||||
var rspResult = webReq.BeginGetResponse(ResponseComplete, webReq);
|
var rspResult = webReq.BeginGetResponse(ResponseComplete, webReq);
|
||||||
ThreadPool.RegisterWaitForSingleObject(rspResult.AsyncWaitHandle, TimeoutCallback, result, 2000, true);
|
ThreadPool.RegisterWaitForSingleObject(rspResult.AsyncWaitHandle, TimeoutCallback, result, 2000,
|
||||||
|
true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -265,6 +267,7 @@ namespace TEngine.Runtime
|
|||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
webReq.Abort();
|
webReq.Abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,6 +287,7 @@ namespace TEngine.Runtime
|
|||||||
yield return time;
|
yield return time;
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -331,7 +335,8 @@ namespace TEngine.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string HttpGet(string url, string postDataStr = "")
|
public static string HttpGet(string url, string postDataStr = "")
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + (postDataStr == "" ? "" : "?") + postDataStr);
|
HttpWebRequest request =
|
||||||
|
(HttpWebRequest)WebRequest.Create(url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||||
request.Method = "GET";
|
request.Method = "GET";
|
||||||
request.ContentType = "text/html;charset=UTF-8";
|
request.ContentType = "text/html;charset=UTF-8";
|
||||||
|
|
||||||
@@ -363,6 +368,7 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
encoding = "UTF-8"; //默认编码
|
encoding = "UTF-8"; //默认编码
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
|
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
|
||||||
string retString = reader.ReadToEnd();
|
string retString = reader.ReadToEnd();
|
||||||
return retString;
|
return retString;
|
||||||
@@ -388,15 +394,17 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
fi.Attributes = FileAttributes.Normal;
|
fi.Attributes = FileAttributes.Normal;
|
||||||
}
|
}
|
||||||
LoaderUtilities.DeleteFile(d);//直接删除其中的文件
|
|
||||||
|
LoaderUtilities.DeleteFile(d); //直接删除其中的文件
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DirectoryInfo d1 = new DirectoryInfo(d);
|
DirectoryInfo d1 = new DirectoryInfo(d);
|
||||||
if (d1.GetFiles().Length != 0)
|
if (d1.GetFiles().Length != 0)
|
||||||
{
|
{
|
||||||
DeleteFolder(d1.FullName);////递归删除子文件夹
|
DeleteFolder(d1.FullName); ////递归删除子文件夹
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.Delete(d, true);
|
Directory.Delete(d, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,7 +473,6 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(srcPath) || !Directory.Exists(srcPath))
|
if (string.IsNullOrEmpty(srcPath) || !Directory.Exists(srcPath))
|
||||||
{
|
{
|
||||||
Debug.LogError("不存在的原目录地址:" + srcPath);
|
Debug.LogError("不存在的原目录地址:" + srcPath);
|
||||||
@@ -486,6 +493,7 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
Directory.CreateDirectory($"{destPath}/{sub_name}");
|
Directory.CreateDirectory($"{destPath}/{sub_name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyDirectory(i.FullName, $"{destPath}/{sub_name}");
|
CopyDirectory(i.FullName, $"{destPath}/{sub_name}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -520,6 +528,7 @@ namespace TEngine.Runtime
|
|||||||
{
|
{
|
||||||
path = Path.GetDirectoryName(path);
|
path = Path.GetDirectoryName(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path == null)
|
if (path == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -577,4 +586,4 @@ namespace TEngine.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user