mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixing folder class when path give does not exist
This commit is contained in:
parent
f9f67a1759
commit
ffe801bb28
2 changed files with 16 additions and 1 deletions
|
@ -161,6 +161,9 @@ class Folder extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function read($sort = true, $exceptions = false, $fullPath = false) {
|
||||
if (!$this->pwd()) {
|
||||
return array();
|
||||
}
|
||||
$dirs = $files = array();
|
||||
|
||||
if (is_array($exceptions)) {
|
||||
|
@ -214,6 +217,9 @@ class Folder extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function findRecursive($pattern = '.*', $sort = false) {
|
||||
if (!$this->pwd()) {
|
||||
return array();
|
||||
}
|
||||
$startsOn = $this->path;
|
||||
$out = $this->_findRecursive($pattern, $sort);
|
||||
$this->cd($startsOn);
|
||||
|
@ -425,6 +431,9 @@ class Folder extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function tree($path, $exceptions = true, $type = null) {
|
||||
if (!$this->pwd()) {
|
||||
return array();
|
||||
}
|
||||
$original = $this->path;
|
||||
$path = rtrim($path, DS);
|
||||
$this->__files = array();
|
||||
|
@ -554,6 +563,9 @@ class Folder extends Object {
|
|||
if (!$path) {
|
||||
$path = $this->pwd();
|
||||
}
|
||||
if (!$path) {
|
||||
return null;
|
||||
}
|
||||
$path = Folder::slashTerm($path);
|
||||
if (is_dir($path) === true) {
|
||||
$normalFiles = glob($path . '*');
|
||||
|
@ -598,6 +610,9 @@ class Folder extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function copy($options = array()) {
|
||||
if (!$this->pwd()) {
|
||||
return false;
|
||||
}
|
||||
$to = null;
|
||||
if (is_string($options)) {
|
||||
$to = $options;
|
||||
|
|
|
@ -95,7 +95,7 @@ class FolderTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testOperations() {
|
||||
$path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel';
|
||||
$path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'templates' . DS . 'skel';
|
||||
$Folder =& new Folder($path);
|
||||
|
||||
$result = is_dir($Folder->pwd());
|
||||
|
|
Loading…
Reference in a new issue