guard against files without extensions and illegal directories
as per @just-boris's suggestions