From 5ae778b1d1f5f0be8d4798f4d6ba58a44faf4baf Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 10 Sep 2024 17:45:42 -0400 Subject: [PATCH] checkPermissions: skip files with an invalid path On Windows files can be created with a trailing " " in their name, which is invalid and cannot be interacted with using the Win32 API, but the underlying filesystem allows. --- .../runelite/launcher/FilesystemPermissions.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/runelite/launcher/FilesystemPermissions.java b/src/main/java/net/runelite/launcher/FilesystemPermissions.java index 798c04f6..ea668117 100644 --- a/src/main/java/net/runelite/launcher/FilesystemPermissions.java +++ b/src/main/java/net/runelite/launcher/FilesystemPermissions.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import javax.swing.SwingUtilities; @@ -182,7 +183,17 @@ private static boolean checkPermissions(File tree, boolean root) } else if (numFiles++ < MAX_FILES_PER_DIRECTORY) { - Path path = file.toPath(); + Path path; + try + { + path = file.toPath(); + } + catch (InvalidPathException ex) + { + log.error("file is not a valid path", ex); + continue; + } + log.debug("Checking permissions of {}", path); if (!Files.isReadable(path) || !Files.isWritable(path)) {