Adapted and extended version of Symfony's Filesystem Class for PHP 5.3+