Adds a directory as module directory

@access public
@param string $directory
@param string $excludePattern
@return boolean
424995
public function registerModuleDirectory($directory, $excludePattern = '/\/tests\//')
    {
        if (!isset($this->moduleDirectories[$directory])) {
            $this->moduleDirectories[$directory] = $excludePattern;
            
            return true;
        }
        
        return false;
    }
590174
protected function find($directory)
    {
        if ($iterator = parent::find($directory)) {
            new Textpattern();

            foreach ($this->manifestNames as $manifestName) {
                foreach ($iterator as $file) {
                    if (basename($file) === $manifestName && $this->isManifest($file)) {
                        $this->dir = dirname($file);
                        $this->import();
                    }
                }

                if (!empty($this->plugin)) {
                    return true;
                }
            }
        }

        return false;
    }
688090
public function setDirectory($directory)
	{
		// trim trailling slash
		$directory = rtrim($directory,"/");
		$dir       = opendir($directory);
		if ($dir === false)
		{
			throw new UnableToSetException("Could not set '$directory'. It is not a directory!");
		}


		while (($file = readdir($dir)) !== false)
		{
			$path      = $directory.'/'.$file;
			$pathInfo  = pathinfo($path);
			$extension = strtolower($pathInfo['extension']);
			$filename  = $pathInfo['filename'];
			if ($extension == 'php')
			{
				$strings = include $path;
				if (is_array($strings))
				{
					$this->collection->setArray($strings, $filename);
				}
			}
		}
		return $this;
	}
337709
public function setCompileDir($dir)
    {
        $this->compileDir = rtrim($dir, '/\\') . DIRECTORY_SEPARATOR;
        if (!file_exists($this->compileDir)) {
            mkdir($this->compileDir, 0777, true);
        }
        if (is_writable($this->compileDir) === false) {
            throw new Exception('The compile directory must be writable, chmod "' . $this->compileDir . '" to make it writable');
        }
    }
1239344
public function setDirectory($directory) {

		if(false === is_string($directory)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($directory)), E_USER_ERROR);
		}

		$this -> directory = new Directory($directory);

		if(false === $this -> directory -> isWritable()) {
			return trigger_error(sprintf('Directory "%s" passed to %s() is not writable', $directory, __METHOD__), E_USER_ERROR);
		}

		return $this;
	}
462807
protected function makeDirs($directory)
	{
		foreach ($directory as $path) {
			if (!$this->files->isDirectory($this->getPath($path))){
				$this->files->makeDirectory($this->getPath($path), 0777, true);
			}
		}
	}
947739
protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty)
    {
        $templateHandles = array();
        $prefix = ($relativePath === '') ? '' : "$relativePath/";
        $matches = null;
        foreach (array_merge(array(''), $this->getDirectoryStructure($rootDirectory, $exclude3rdParty)) as $child) {
            $shownChild = ($child === '') ? rtrim($prefix, '/') : ($prefix.$child);
            $fullpath = ($child === '') ? $rootDirectory : "$rootDirectory/$child";
            if (preg_match('%(?:^|/)blocks/\w+/(?:templates|composer)/(\w+)$%', $fullpath, $matches)) {
                if (!isset($templateHandles[$matches[1]])) {
                    $templateHandles[$matches[1]] = array();
                }
                $templateHandles[$matches[1]][] = $shownChild;
            } elseif (preg_match('%(^|/)blocks/\w+/(?:templates|composer)$%', $fullpath)) {
                $contents = @scandir($fullpath);
                if ($contents === false) {
                    throw new \Exception("Unable to parse directory $fullpath");
                }
                foreach ($contents as $file) {
                    if ($file[0] !== '.') {
                        if (preg_match('/^(.*)\.php$/', $file, $matches) && is_file("$fullpath/$file")) {
                            if (!isset($templateHandles[$matches[1]])) {
                                $templateHandles[$matches[1]] = array();
                            }
                            $templateHandles[$matches[1]][] = $shownChild."/$file";
                        }
                    }
                }
            }
        }
        foreach ($templateHandles as $templateHandle => $references) {
            $translation = $translations->insert('TemplateFileName', ucwords(str_replace(array('_', '-', '/'), ' ', $templateHandle)));
            foreach ($references as $reference) {
                $translation->addReference($reference);
            }
        }
    }
536135
public function setIncludePolicy($allow, $directory = null)
    {
        $this->includeAllowed = !empty($allow);
        if ($directory !== null) {
            $this->includeRoot = (string) $directory;
        }
        return $this;
    }
483926
static function chdir($dir, $callback = null, $argv = array())
    {
        if (!is_dir($dir)) {
            throw new \InvalidArgumentException("$dir does not exist.");
        }

        $cwd = getcwd();
        chdir($dir);

        if (null === $callback) {
            return;
        }

        $returnValue = call_user_func_array($callback, $argv);

        chdir($cwd);
        return $returnValue;
    }
1140604
public static function readDir($dir, $exclude = ".|..|.svn|.git", $recursive = false)
    {
        $file_list_array = array();
        $base_path = $dir;
        $exclude_array = explode("|", $exclude);
        $exclude_array = array_unique(array_merge($exclude_array, array('.', '..')));

        if ($recursive) {
            foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $new_file) {
                if ($new_file->isDir()) continue;
                $object = str_replace($base_path, '', $new_file);
                if (!in_array(strtolower($object), $exclude_array)) {
                    $object = ltrim($object, '/');
                    if (is_file($new_file)) {
                        $key = md5($new_file . $object, false);
                        $file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
                    }
                }
            }
        } else if ($handle = opendir($dir)) {
            while (false !== ($file = readdir($handle))) {
                if (!in_array(strtolower($file), $exclude_array)) {
                    $new_file = $dir . '/' . $file;
                    $object = $file;
                    $object = ltrim($object, '/');
                    if (is_file($new_file)) {
                        $key = md5($new_file . $object, false);
                        $file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
                    }
                }
            }
            closedir($handle);
        }
        return $file_list_array;
    }
713906
public function setDirectory($directory)
    {
        if (!is_dir($directory) && !is_writable($directory)) {
            throw new FileCacheException(
                sprintf('The directory "%s" is not directory and not writable', $directory)
            );
        }

        if (is_null($directory) && !$this->getFilesystem()->mkdir($directory, 0777, true)) {
            throw new FileCacheException(
                sprintf('The directory "%s" not be null and directory not be created')
            );
        }

        $this->directory = realpath($directory);
    }
622636
function addExclude($exclude) {
        $exclude = func_get_args();
        foreach($exclude as $v) {
            $this->exclude = array_merge($this->exclude, (array) $v);
        }
        
        return $this;
    }
741230
public function excludeFilesFrom($excludeFilesAndDirectories): self
    {
        $this->excludeFilesAndDirectories = $this->excludeFilesAndDirectories->merge($this->sanitize($excludeFilesAndDirectories));

        return $this;
    }
51348
public void addModuleDir(final String moduleDir) {
        if (moduleDir == null) {
            throw LauncherMessages.MESSAGES.nullParam("moduleDir");
        }
        // Validate the path
        final Path path = Paths.get(moduleDir).normalize();
        modulesDirs.add(path.toString());
    }
44714
public static function addDirectory($directory = '.')
    {
        $directory = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $directory);
        $directory = rtrim($directory, '/\\');
        $directory = empty($directory) ? '.' : $directory;
        array_push(self::$configDirectory, $directory);
        return true;
    }
963547
protected function makeActualDirectory($directory, $mode)
    {
        $connection = $this->getConnection();

        $directories = ftp_nlist($connection, '.') ?: [];

        // Remove unix characters from directory name
        array_walk($directories, function ($dir_name, $key) {
            return preg_match('~^\./.*~', $dir_name) ? substr($dir_name, 2) : $dir_name;
        });


        // Skip directory creation if it already exists
        if (in_array($directory, $directories, true)) {
            return true;
        }

        return ftp_mkdir($connection, $directory);
    }
523218
protected function createDir($dir)
    {
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            throw new \RuntimeException(
                sprintf('Unable to create cache directory %s, check permissions', $dir)
            );
        }

        if (!is_writable($dir)) {
            throw new BadPermissionException(
                sprintf('Cache directory %s is not writable, check permissions', $dir)
            );
        }
    }