Prevent infinite loop with dirname
Prevent infinite loop with dirname

Added $dir != dirname($dir) to ensure that we stop if we encounter the
same directory twice. In particular, this happens when $dir = '/',
because dirname('/') == '/'.

AlexMasterov/framework