Fix getting extension of files with dots in dirname.