* @throws InvalidPathException
* if the path is invalid
* @since 3.3
*/
public static void checkValidPath(String path) throws InvalidPathException {
ObjectChecker chk = new ObjectChecker()
.setSafeForWindows(SystemReader.getInstance().isWindows())
.setSafeForMacOS(SystemReader.getInstance().isMacOS());
byte[] bytes = Constants.encode(path);
int segmentStart = 0;
try {
for (int i = 0; i < bytes.length; i++) {
if (bytes[i] == '/') {
chk.checkPathSegment(bytes, segmentStart, i);
segmentStart = i + 1;
}
}
chk.checkPathSegment(bytes, segmentStart, bytes.length);
} catch (CorruptObjectException e) {
throw new InvalidPathException(e.getMessage());
}
}