Fix issue #6812: directory_mode does not work

This pull request fixes issue #6812.