Improved directory write checking