Don't use directory when it's empty. fix #1448