Skip to content

Commit 4319407

Browse files
author
Jiang Yin
committed
修改压缩接口
1 parent 8217d64 commit 4319407

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Scripts/Runtime/Utility/DefaultZipHelper.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ public byte[] Compress(byte[] bytes)
3939
}
4040

4141
result = memoryStream.ToArray();
42+
43+
if (result.Length >= 8)
44+
{
45+
result[4] = 25;
46+
result[5] = 134;
47+
result[6] = 2;
48+
result[7] = 32;
49+
}
50+
}
51+
catch
52+
{
53+
4254
}
4355
finally
4456
{
@@ -49,14 +61,6 @@ public byte[] Compress(byte[] bytes)
4961
}
5062
}
5163

52-
if (result != null && result.Length >= 8)
53-
{
54-
result[4] = 25;
55-
result[5] = 134;
56-
result[6] = 2;
57-
result[7] = 32;
58-
}
59-
6064
return result;
6165
}
6266

@@ -69,7 +73,7 @@ public byte[] Decompress(byte[] bytes)
6973
{
7074
if (bytes == null || bytes.Length <= 0)
7175
{
72-
return bytes;
76+
return null;
7377
}
7478

7579
MemoryStream decompressedStream = null;
@@ -91,6 +95,10 @@ public byte[] Decompress(byte[] bytes)
9195

9296
return decompressedStream.ToArray();
9397
}
98+
catch
99+
{
100+
return null;
101+
}
94102
finally
95103
{
96104
if (decompressedStream != null)

0 commit comments

Comments
 (0)