/** * Delete those files from the given directory, which results true value on checkDelete function * * @static * * @param string directory path * @param string the first error occured deleting the directory content */ function deleteDirContent($path, &$first_error) { $path = trailing_slash($path); if ($dir = @opendir($path)) { while (($file = readdir($dir)) !== false) { if ($file == '.' || $file == '..') { continue; } $file_path = $path . $file; if (is_dir($file_path)) { PageCache::deleteDirContent($file_path, $first_error); } else { if (PageCache::checkDelete($file_path)) { if (!@unlink($file_path) && $first_error == '') { // deleting the file failed: return error //$error = error_get_last(); // XXX: requires PHP 5.2 //$error['message']; $first_error = sprintf(T_('Some files could not be deleted (including: %s).'), $file); } } } } } else { if ($first_error == '') { $first_error = sprintf(T_('Can not access directory: %s.'), $path); } } }