Guard the write access to the m_directoryCache member with a lock

Based on TortoiseSVN revision 25186

Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com>