Skip to content

Commit

Permalink
Fix empty $path triggering a warning, and failing on Windows.
Browse files Browse the repository at this point in the history
Slash terminating a path requires reading the last char of the path,
which will fail on an empty string. Also on Windows the assumed
top level path should use the proper backward slash.
  • Loading branch information
ndm2 committed Aug 24, 2016
1 parent 949bde9 commit 678084a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Filesystem/Folder.php
Expand Up @@ -418,12 +418,17 @@ public function inCakePath($path = '')
/**
* Returns true if the Folder is in the given path.
*
* @param string $path The absolute path to check that the current `pwd()` resides within.
* @param string $path The absolute path to check that the current `pwd()` resides within. If omitted
* (or empty), the current top level directory is assumed.
* @param bool $reverse Reverse the search, check if the given `$path` resides within the current `pwd()`.
* @return bool
*/
public function inPath($path = '', $reverse = false)
{
if (empty($path)) {
$path = DS;
}

$dir = Folder::slashTerm($path);
$current = Folder::slashTerm($this->pwd());

Expand Down

0 comments on commit 678084a

Please sign in to comment.