Skip to content

Commit

Permalink
修复Windows平台打包时会有文件名大小写敏感的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
asforest committed May 21, 2023
1 parent 42b8334 commit 5d2781a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/mcpatch/diff/DirectoryDiff.kt
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ class DirectoryDiff
append("旧目录: $f\n")

for (f in missingFolders)
append("新目录: $f")
append("新目录: $f\n")

for (f in redundantFiles)
append("旧文件: $f")
append("旧文件: $f\n")

for (f in missingFiles)
{
Expand Down
16 changes: 16 additions & 0 deletions src/main/kotlin/mcpatch/interactive/Create.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.apache.commons.compress.archivers.zip.ZipFile
import org.apache.tools.bzip2.CBZip2OutputStream
import java.io.ByteArrayOutputStream
import java.util.*
import kotlin.math.max

class Create
Expand Down Expand Up @@ -154,6 +155,21 @@ class Create
println("没有任何文件改动,即将创建一个空版本")
}

// 检测仅修改大小写的问题
val mfs = diff.missingFiles.map { it.lowercase(Locale.getDefault()) }.toList()
val nfs = diff.redundantFiles .map { it.lowercase(Locale.getDefault()) }.toList()
val collided = mfs.firstOrNull { it in nfs }

if (collided != null)
throw McPatchManagerException("无法打包仅修改大小写文件名的文件:$collided")

val ff1 = diff.moveFiles.map { it.first.lowercase(Locale.getDefault()) }.toList()
val tf1 = diff.moveFiles.map { it.second.lowercase(Locale.getDefault()) }.toList()
val collided1 = ff1.firstOrNull { it in tf1 }
if (collided1 != null)
throw McPatchManagerException("无法打包仅修改大小写文件名的文件:$collided1")


// 提示输入版本号
println("输入你要创建的版本号名称,目前最新版本号为 ${versionL.getNewest()}")
val version = versionSpecified ?: Input.readAnyString().trim()
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/mcpatch/interactive/Status.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mcpatch.interactive
import mcpatch.McPatchManage
import mcpatch.diff.DirectoryDiff
import mcpatch.diff.RealFile
import java.util.*

class Status
{
Expand Down

0 comments on commit 5d2781a

Please sign in to comment.