"Fixes #4414, Folder::!__tree() causing warnings when apache user has no read access to a folder"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6624 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2008-04-02 19:35:14 +00:00
parent 358c529e7a
commit 2db0f954c1

View file

@ -148,8 +148,8 @@ class Folder extends Object{
*/ */
function read($sort = true, $exceptions = false) { function read($sort = true, $exceptions = false) {
$dirs = $files = array(); $dirs = $files = array();
$dir = opendir($this->path);
if ($dir !== false) { if ($dir = @opendir($this->path)) {
while (false !== ($n = readdir($dir))) { while (false !== ($n = readdir($dir))) {
$item = false; $item = false;
if (is_array($exceptions)) { if (is_array($exceptions)) {
@ -433,9 +433,7 @@ class Folder extends Object{
* @access private * @access private
*/ */
function __tree($path, $hidden) { function __tree($path, $hidden) {
if (is_dir($path)) { if (is_dir($path) && $dirHandle = @opendir($path)) {
$dirHandle = @opendir($path);
while (false !== ($item = @readdir($dirHandle))) { while (false !== ($item = @readdir($dirHandle))) {
$found = false; $found = false;
@ -548,7 +546,7 @@ class Folder extends Object{
continue; continue;
} }
if (is_file($file) === true) { if (is_file($file) === true) {
if (unlink($file)) { if (@unlink($file)) {
$this->__messages[] = sprintf(__('%s removed', true), $path); $this->__messages[] = sprintf(__('%s removed', true), $path);
} else { } else {
$this->__errors[] = sprintf(__('%s NOT removed', true), $path); $this->__errors[] = sprintf(__('%s NOT removed', true), $path);
@ -604,8 +602,8 @@ class Folder extends Object{
} }
$exceptions = array_merge(array('.','..','.svn'), $options['skip']); $exceptions = array_merge(array('.','..','.svn'), $options['skip']);
$handle = opendir($fromDir);
if ($handle) { if ($handle = @opendir($fromDir)) {
while (false !== ($item = readdir($handle))) { while (false !== ($item = readdir($handle))) {
if (!in_array($item, $exceptions)) { if (!in_array($item, $exceptions)) {
$from = $this->addPathElement($fromDir, $item); $from = $this->addPathElement($fromDir, $item);