mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #5001 from cakephp/issue-4990
Relative paths should be created relative to pwd.
This commit is contained in:
commit
a0aac5cfa9
2 changed files with 26 additions and 3 deletions
|
@ -170,6 +170,22 @@ class FolderTest extends CakeTestCase {
|
||||||
$this->assertTrue($Folder->delete());
|
$this->assertTrue($Folder->delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that relative paths to create() are added to cwd.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testCreateRelative() {
|
||||||
|
$folder = new Folder(TMP);
|
||||||
|
$path = TMP . 'tests' . DS . 'relative-test';
|
||||||
|
$result = $folder->create('tests' . DS . 'relative-test');
|
||||||
|
$this->assertTrue($result, 'should create');
|
||||||
|
|
||||||
|
$this->assertTrue(is_dir($path), 'Folder was not made');
|
||||||
|
$folder = new Folder($path);
|
||||||
|
$folder->delete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test recursive directory create failure.
|
* test recursive directory create failure.
|
||||||
*
|
*
|
||||||
|
|
|
@ -487,10 +487,13 @@ class Folder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a directory structure recursively. Can be used to create
|
* Create a directory structure recursively.
|
||||||
* deep path structures like `/foo/bar/baz/shoe/horn`
|
|
||||||
*
|
*
|
||||||
* @param string $pathname The directory structure to create
|
* Can be used to create deep path structures like `/foo/bar/baz/shoe/horn`
|
||||||
|
*
|
||||||
|
* @param string $pathname The directory structure to create. Either an absolute or relative
|
||||||
|
* path. If the path is relative and exists in the process' cwd it will not be created.
|
||||||
|
* Otherwise relative paths will be prefixed with the current pwd().
|
||||||
* @param int $mode octal value 0755
|
* @param int $mode octal value 0755
|
||||||
* @return bool Returns TRUE on success, FALSE on failure
|
* @return bool Returns TRUE on success, FALSE on failure
|
||||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#Folder::create
|
||||||
|
@ -500,6 +503,10 @@ class Folder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!self::isAbsolute($pathname)) {
|
||||||
|
$pathname = self::addPathElement($this->pwd(), $pathname);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$mode) {
|
if (!$mode) {
|
||||||
$mode = $this->mode;
|
$mode = $this->mode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue