Remove trailing spaces and periods from filenames
This commit is contained in:
1 parent
d4c64f6e66
commit
20a4f4ab25
1 file changed
+3
-3
@@ -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)) {
|
||||
|
||||
Reference in new issue
Block a user