Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
21abfe4a
Commit
21abfe4a
authored
Mar 08, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix zip and unzip
parent
243b2ea7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
22 deletions
+34
-22
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt
...droidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt
+5
-11
mirai-core/src/commonTest/kotlin/net.mamoe.mirai.utils/PlatformUtilsTest.kt
...monTest/kotlin/net.mamoe.mirai.utils/PlatformUtilsTest.kt
+24
-0
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
.../jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
+5
-11
No files found.
mirai-core/src/androidMain/kotlin/net/mamoe/mirai/utils/platformAndroid.kt
View file @
21abfe4a
...
...
@@ -54,18 +54,12 @@ actual object MiraiPlatformUtils {
data
.
checkOffsetAndLength
(
offset
,
length
)
if
(
length
==
0
)
return
ByteArray
(
0
)
val
inflater
=
Deflater
()
inflater
.
reset
()
ByteArrayOutputStream
().
use
{
output
->
inflater
.
setInput
(
data
,
offset
,
length
)
ByteArrayPool
.
useInstance
{
while
(!
inflater
.
finished
())
{
output
.
write
(
it
,
0
,
inflater
.
deflate
(
it
))
}
}
val
deflater
=
Deflater
()
deflater
.
setInput
(
data
,
offset
,
length
)
deflater
.
finish
()
inflater
.
end
()
return
output
.
toByteArray
()
ByteArrayPool
.
useInstance
{
return
it
.
take
(
deflater
.
deflate
(
it
)).
toByteArray
().
also
{
deflater
.
end
()
}
}
}
...
...
mirai-core/src/commonTest/kotlin/net.mamoe.mirai.utils/PlatformUtilsTest.kt
0 → 100644
View file @
21abfe4a
/*
* Copyright 2020 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package
net.mamoe.mirai.utils
import
kotlinx.io.core.toByteArray
import
net.mamoe.mirai.utils.io.encodeToString
import
kotlin.test.Test
import
kotlin.test.assertEquals
internal
class
PlatformUtilsTest
{
@OptIn
(
MiraiInternalAPI
::
class
)
@Test
fun
testZip
()
{
assertEquals
(
"test"
,
MiraiPlatformUtils
.
unzip
(
MiraiPlatformUtils
.
zip
(
"test"
.
toByteArray
())).
encodeToString
())
}
}
\ No newline at end of file
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/PlatformUtilsJvm.kt
View file @
21abfe4a
...
...
@@ -55,18 +55,12 @@ actual object MiraiPlatformUtils {
data
.
checkOffsetAndLength
(
offset
,
length
)
if
(
length
==
0
)
return
ByteArray
(
0
)
val
inflater
=
Deflater
()
inflater
.
reset
()
ByteArrayOutputStream
().
use
{
output
->
inflater
.
setInput
(
data
,
offset
,
length
)
ByteArrayPool
.
useInstance
{
while
(!
inflater
.
finished
())
{
output
.
write
(
it
,
0
,
inflater
.
deflate
(
it
))
}
}
val
deflater
=
Deflater
()
deflater
.
setInput
(
data
,
offset
,
length
)
deflater
.
finish
()
inflater
.
end
()
return
output
.
toByteArray
()
ByteArrayPool
.
useInstance
{
return
it
.
take
(
deflater
.
deflate
(
it
)).
toByteArray
().
also
{
deflater
.
end
()
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment