fix a bug in directory.cpp