diff --git a/src/bootstrap.php b/src/bootstrap.php index 1702896..894af2f 100755 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -35,6 +35,6 @@ function bootstrap($cwd, $home) { } // Always add current directory - $result['local'][]= path($cwd); + $result['local'][]= path($cwd, $cwd, $home); return $result; } \ No newline at end of file diff --git a/src/scan-path.php b/src/scan-path.php index 97af56f..b9a9fa6 100755 --- a/src/scan-path.php +++ b/src/scan-path.php @@ -1,6 +1,14 @@ 2 && (':' === $path[1] && '\\' === $path[2])) { + $in= $path; + } else { + $in= $base.DIRECTORY_SEPARATOR.$path; + } + $qn= realpath($in); if (false === $qn) { if ($bail) { @@ -47,19 +55,14 @@ function scanpath(&$result, $paths, $base, $home) { } else if ('?' === $path[0]) { $bail= false; $path= substr($path, 1); - } - - // Expand file path - if ('~' === $path[0]) { - $expanded= $home.DIRECTORY_SEPARATOR.substr($path, 1); - } else if ('/' === $path[0] || '\\' === $path[0] || strlen($path) > 2 && (':' === $path[1] && '\\' === $path[2])) { - $expanded= $path; - } else { - $expanded= $base.DIRECTORY_SEPARATOR.$path; + } else if ('@' === $path[0]) { + $resolved= path(substr($path, 1), $base, $home); + scanpath($result, pathfiles($resolved), $resolved, $home); + continue; } // Resolve, check for XP core - if ($resolved= path($expanded, $bail)) { + if ($resolved= path($path, $base, $home, $bail)) { if (null === $result['base']) { if (0 === substr_compare($resolved, '.xar', -4)) { if (is_file($f= 'xar://'.$resolved.'?__xp.php')) { diff --git a/test/shared/scan-path-test.php b/test/shared/scan-path-test.php index 54ddc0b..c02a7de 100755 --- a/test/shared/scan-path-test.php +++ b/test/shared/scan-path-test.php @@ -118,5 +118,20 @@ function() { $result= ['base' => null]; \xp\scanpath($result, ['does-not-exist'] 'empty use path does not raise warnings' => function() use($path) { $result= ['base' => null]; \xp\scanpath($result, [''], $this->classpath, $this->home); + }, + + // Includes + 'module reference to home directory' => function() use($path) { + $result= ['base' => null]; + file_put_contents($path->compose($this->devel, 'class.pth'), '.'); + \xp\scanpath($result, ['@~/devel'], $this->classpath, $this->home); + $this->assertEquals(['base' => null, 'local' => [$this->devel]], $result); + }, + + 'module reference to relative directory' => function() use($path) { + $result= ['base' => null]; + file_put_contents($path->compose($this->home, 'class.pth'), '.'); + \xp\scanpath($result, ['@home'], $this->classpath, $this->home); + $this->assertEquals(['base' => null, 'local' => [$this->home]], $result); } -])); +])); \ No newline at end of file