protected function changeMode($path, $mode)
    {
        $oldPermission = substr(sprintf('%o', fileperms($path)), -4);
        $newPermission = sprintf('%04o', $mode);
        if ($oldPermission !== $newPermission) {
            if(!@chmod($path, $mode)) {
                throw new CException (sprintf("Unable to change mode for %s, permission denied", $path));
            }
            echo sprintf("Changing mode for %s (%s => %s)... ", $path, $oldPermission, $newPermission);
            echo "done\n";
        }
    }