mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-28 03:28:47 +00:00
refactor #627
This commit is contained in:
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageFileCRC { set; get; }
|
public uint PackageFileCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
|||||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
return "00000000"; //8位
|
return 0;
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
|||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32Value(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileCRC;
|
public uint FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
|
|||||||
@@ -505,22 +505,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
||||||
public void WriteBundleInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
public void WriteBundleInfoFile(string filePath, uint dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||||
{
|
{
|
||||||
_sharedBuffer.Clear();
|
_sharedBuffer.Clear();
|
||||||
_sharedBuffer.WriteUTF8(dataFileCRC);
|
_sharedBuffer.WriteUInt32(dataFileCRC);
|
||||||
_sharedBuffer.WriteInt64(dataFileSize);
|
_sharedBuffer.WriteInt64(dataFileSize);
|
||||||
_sharedBuffer.WriteToStream(fs);
|
_sharedBuffer.WriteToStream(fs);
|
||||||
fs.Flush();
|
fs.Flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void ReadBundleInfoFile(string filePath, out string dataFileCRC, out long dataFileSize)
|
public void ReadBundleInfoFile(string filePath, out uint dataFileCRC, out long dataFileSize)
|
||||||
{
|
{
|
||||||
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
||||||
BufferReader buffer = new BufferReader(binaryData);
|
BufferReader buffer = new BufferReader(binaryData);
|
||||||
dataFileCRC = buffer.ReadUTF8();
|
dataFileCRC = buffer.ReadUInt32();
|
||||||
dataFileSize = buffer.ReadInt64();
|
dataFileSize = buffer.ReadInt64();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public string InfoFilePath { private set; get; }
|
public string InfoFilePath { private set; get; }
|
||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string DataFileCRC { private set; get; }
|
public uint DataFileCRC { private set; get; }
|
||||||
public long DataFileSize { private set; get; }
|
public long DataFileSize { private set; get; }
|
||||||
|
|
||||||
public RecordFileElement(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
public RecordFileElement(string infoFilePath, string dataFilePath, uint dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
InfoFilePath = infoFilePath;
|
InfoFilePath = infoFilePath;
|
||||||
DataFilePath = dataFilePath;
|
DataFilePath = dataFilePath;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace YooAsset
|
|||||||
internal class TempFileElement
|
internal class TempFileElement
|
||||||
{
|
{
|
||||||
public string TempFilePath { private set; get; }
|
public string TempFilePath { private set; get; }
|
||||||
public string TempFileCRC { private set; get; }
|
public uint TempFileCRC { private set; get; }
|
||||||
public long TempFileSize { private set; get; }
|
public long TempFileSize { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public volatile int Result = 0;
|
public volatile int Result = 0;
|
||||||
|
|
||||||
public TempFileElement(string filePath, string fileCRC, long fileSize)
|
public TempFileElement(string filePath, uint fileCRC, long fileSize)
|
||||||
{
|
{
|
||||||
TempFilePath = filePath;
|
TempFilePath = filePath;
|
||||||
TempFileCRC = fileCRC;
|
TempFileCRC = fileCRC;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset
|
|||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string InfoFilePath { private set; get; }
|
public string InfoFilePath { private set; get; }
|
||||||
|
|
||||||
public string DataFileCRC;
|
public uint DataFileCRC;
|
||||||
public long DataFileSize;
|
public long DataFileSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验
|
/// 文件校验
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EFileVerifyResult FileVerify(string filePath, long fileSize, string fileCRC, EFileVerifyLevel verifyLevel)
|
public static EFileVerifyResult FileVerify(string filePath, long fileSize, uint fileCRC, EFileVerifyLevel verifyLevel)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
|||||||
// 再验证文件CRC
|
// 再验证文件CRC
|
||||||
if (verifyLevel == EFileVerifyLevel.High)
|
if (verifyLevel == EFileVerifyLevel.High)
|
||||||
{
|
{
|
||||||
string crc = HashUtility.FileCRC32(filePath);
|
uint crc = HashUtility.FileCRC32Value(filePath);
|
||||||
if (crc == fileCRC)
|
if (crc == fileCRC)
|
||||||
return EFileVerifyResult.Succeed;
|
return EFileVerifyResult.Succeed;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件格式版本
|
/// 文件格式版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string FileVersion = "2.3.1";
|
public const string FileVersion = "2025.8.28";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ namespace YooAsset
|
|||||||
buffer.WriteUTF8(packageBundle.BundleName);
|
buffer.WriteUTF8(packageBundle.BundleName);
|
||||||
buffer.WriteUInt32(packageBundle.UnityCRC);
|
buffer.WriteUInt32(packageBundle.UnityCRC);
|
||||||
buffer.WriteUTF8(packageBundle.FileHash);
|
buffer.WriteUTF8(packageBundle.FileHash);
|
||||||
buffer.WriteUTF8(packageBundle.FileCRC);
|
buffer.WriteUInt32(packageBundle.FileCRC);
|
||||||
buffer.WriteInt64(packageBundle.FileSize);
|
buffer.WriteInt64(packageBundle.FileSize);
|
||||||
buffer.WriteBool(packageBundle.Encrypted);
|
buffer.WriteBool(packageBundle.Encrypted);
|
||||||
buffer.WriteUTF8Array(packageBundle.Tags);
|
buffer.WriteUTF8Array(packageBundle.Tags);
|
||||||
@@ -190,7 +190,7 @@ namespace YooAsset
|
|||||||
packageBundle.BundleName = buffer.ReadUTF8();
|
packageBundle.BundleName = buffer.ReadUTF8();
|
||||||
packageBundle.UnityCRC = buffer.ReadUInt32();
|
packageBundle.UnityCRC = buffer.ReadUInt32();
|
||||||
packageBundle.FileHash = buffer.ReadUTF8();
|
packageBundle.FileHash = buffer.ReadUTF8();
|
||||||
packageBundle.FileCRC = buffer.ReadUTF8();
|
packageBundle.FileCRC = buffer.ReadUInt32();
|
||||||
packageBundle.FileSize = buffer.ReadInt64();
|
packageBundle.FileSize = buffer.ReadInt64();
|
||||||
packageBundle.Encrypted = buffer.ReadBool();
|
packageBundle.Encrypted = buffer.ReadBool();
|
||||||
packageBundle.Tags = buffer.ReadUTF8Array();
|
packageBundle.Tags = buffer.ReadUTF8Array();
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ namespace YooAsset
|
|||||||
packageBundle.BundleName = _buffer.ReadUTF8();
|
packageBundle.BundleName = _buffer.ReadUTF8();
|
||||||
packageBundle.UnityCRC = _buffer.ReadUInt32();
|
packageBundle.UnityCRC = _buffer.ReadUInt32();
|
||||||
packageBundle.FileHash = _buffer.ReadUTF8();
|
packageBundle.FileHash = _buffer.ReadUTF8();
|
||||||
packageBundle.FileCRC = _buffer.ReadUTF8();
|
packageBundle.FileCRC = _buffer.ReadUInt32();
|
||||||
packageBundle.FileSize = _buffer.ReadInt64();
|
packageBundle.FileSize = _buffer.ReadInt64();
|
||||||
packageBundle.Encrypted = _buffer.ReadBool();
|
packageBundle.Encrypted = _buffer.ReadBool();
|
||||||
packageBundle.Tags = _buffer.ReadUTF8Array();
|
packageBundle.Tags = _buffer.ReadUTF8Array();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileCRC;
|
public uint FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
|
|||||||
Reference in New Issue
Block a user