This part of cleanPathString was supposed to de-dupe backslashes in the directory name, and then insert a backslash to the start of directory if the directory originally started with \\ (so that the string again started with \\). However, because the call to rDirectory.replace was specifying a length of 1, it was always replacing \ with \ instead of replacing \\ with \. When the backslash was then inserted at the start of the directory, the directory string now began with \\\ instead of \\. This broke the ROM browser when using a network share (such as \\myserver\Emulation\Games).
Miserably hated doing this commit. Couldn't tell which code was whose, which was copyrighted, which was foreign enough to Project64 that I'd probably best just leave-as is, which was even worth considering part of Project64, which cleanups to omit doing and ignore because some ugly practices were rampant throughout the entire file and distracted from the purpose of this pull request too much. So tried to stick to mostly just the braces/indentation changes here.