PathTool.getRelativeFilePath() has a broken regex for matching Windows drive letters at lines 146 and 149:
if (toPath.matches("^\\[a-zA-Z]:")) {
toPath = toPath.substring(1);
}
The regex ^\\[a-zA-Z]: contains an erroneous \ before [, so instead of matching a backslash + drive letter (e.g. \C:), it matches the literal string [a-zA-Z]:. The intent was to match a leading backslash followed by a drive letter — paths like \C:\foo that File.getPath() can produce on Windows when given /C:/foo.
The correct regex should be ^\\\\[a-zA-Z]: which in a Java string becomes "^\\\\[a-zA-Z]:" — matching a literal backslash, a letter, and a colon at the start of the string.
This means the drive-letter normalization code is effectively dead on Windows, causing incorrect relative paths or null returns when paths have a leading separator before the drive letter.
PathTool.getRelativeFilePath()has a broken regex for matching Windows drive letters at lines 146 and 149:The regex
^\\[a-zA-Z]:contains an erroneous\before[, so instead of matching a backslash + drive letter (e.g.\C:), it matches the literal string[a-zA-Z]:. The intent was to match a leading backslash followed by a drive letter — paths like\C:\foothatFile.getPath()can produce on Windows when given/C:/foo.The correct regex should be
^\\\\[a-zA-Z]:which in a Java string becomes"^\\\\[a-zA-Z]:"— matching a literal backslash, a letter, and a colon at the start of the string.This means the drive-letter normalization code is effectively dead on Windows, causing incorrect relative paths or
nullreturns when paths have a leading separator before the drive letter.