From 20a4f4ab2583b7f521606e8c47cf5584b78c5a63 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Wed, 12 Nov 2025 22:46:53 +0800 Subject: [PATCH] Remove trailing spaces and periods from filenames --- app/src/main/kotlin/com/hippo/ehviewer/util/FileUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/util/FileUtils.kt b/app/src/main/kotlin/com/hippo/ehviewer/util/FileUtils.kt index 39f2d07a8..0fe3cba94 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/util/FileUtils.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/util/FileUtils.kt @@ -79,9 +79,9 @@ object FileUtils { */ // From https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/FileUtils.java;l=1142;drc=7b647e4ea0e92f33c19b315eaed364ee067ba0aa fun sanitizeFilename(name: String): String { - if (name.isEmpty() || "." == name || ".." == name) { - return "(invalid)" - } + // Windows does not support filenames ending with a space or a period + val name = name.trimEnd(' ', '.') + check(name.isNotEmpty()) { "Invalid filename" } return buildString(name.length) { name.forEach { if (isValidFatFilenameChar(it)) {