Maybe we should just use apache.commons.io.FilenameUtils for these operations for now, rather than write them all ourselves. This would mean we don't have control over the path separator, but the apache library says it handles this itself.