AppserverIo\Appserver\Core\Api\AbstractService::globDir PHP Method

globDir() public method

Parses and returns the directories and files that matches the passed glob pattern in a recursive way (if wanted).
public globDir ( string $pattern, integer $flags, boolean $recursive = true ) : array
$pattern string The glob pattern used to parse the directories
$flags integer The flags passed to the glob function
$recursive boolean Whether or not to parse directories recursively
return array The directories matches the passed glob pattern
    public function globDir($pattern, $flags = 0, $recursive = true)
    {
        return FileSystem::globDir($pattern, $flags, $recursive);
    }

Usage Example

 /**
  * Rests if we can glob directories and files as we should
  *
  * @return null
  */
 public function testGlobDir()
 {
     $tmpDir = $this->getTmpDir() . DIRECTORY_SEPARATOR;
     touch($tmpDir . 'globMe1');
     \mkdir($tmpDir . 'globMeAsWell');
     touch($tmpDir . 'dontGlobMe');
     $files = $this->service->globDir($tmpDir . 'globMe*');
     $this->assertContains($tmpDir . 'globMe1', $files);
     $this->assertContains($tmpDir . 'globMeAsWell', $files);
     $this->assertNotContains($tmpDir . 'dontGlobMe', $files);
 }