Skip to content

Commit

Permalink
checkPermissions: skip files with an invalid path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Adam- committed Sep 10, 2024
1 parent 3195b1e commit 5ae778b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/net/runelite/launcher/FilesystemPermissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
{
Expand Down

0 comments on commit 5ae778b

Please sign in to comment.