Fix #4333 (Files incorrectly identified as plain text if folder's name has got the "#" char)

Replaced usage of PathUtils (inappropriate for the task) with new FileUtils.getBaseName. JSDoc and unit tests included.