open given dir as current maildir

@param string $dirname name of maildir
@return null
@throws Zend_Mail_Storage_Exception
421886
protected function _openMaildir($dirname)
    {
        if ($this->_files) {
            $this->close();
        }

        $dh = @opendir($dirname . '/cur/');
        if (!$dh) {
            /**
             * @see Zend_Mail_Storage_Exception
             */
            // require_once 'Zend/Mail/Storage/Exception.php';
            throw new Zend_Mail_Storage_Exception('cannot open maildir');
        }
        $this->_getMaildirFiles($dh, $dirname . '/cur/');
        closedir($dh);

        $dh = @opendir($dirname . '/new/');
        if ($dh) {
            $this->_getMaildirFiles($dh, $dirname . '/new/', array(Zend_Mail_Storage::FLAG_RECENT));
            closedir($dh);
        } else if (file_exists($dirname . '/new/')) {
            /**
             * @see Zend_Mail_Storage_Exception
             */
            // require_once 'Zend/Mail/Storage/Exception.php';
            throw new Zend_Mail_Storage_Exception('cannot read recent mails in maildir');
        }
    }
1002743
public function directories($dirname = '.')
    {
        $listing = $this->listDirectoryContents($dirname);

        return array_values(array_filter($listing, function ($item) {
            return $item['type'] === 'directory';
        }));
    }
326714
protected static function getLocalConfiguration($dirname)
    {
        if (is_dir($dirname) && empty(self::$localConfigurations[$dirname])) {
            $localConfig                         = $dirname.DIRECTORY_SEPARATOR.'local.json';
            self::$localConfigurations[$dirname] = file_exists($localConfig) ?
                (array)@\json_decode(file_get_contents($localConfig)) : [];
        }

        return self::$localConfigurations[$dirname];
    }
890210
public function makeDirectory($dirname, $mode = 0777)
    {
        $connection = $this->getConnection();

        $directories = explode('/', $dirname);

        foreach ($directories as $directory) {
            if (false === $this->makeActualDirectory($directory, $mode)) {
                $this->setConnectionRoot();
                return false;
            }
            ftp_chdir($connection, $directory);
        }

        $this->setConnectionRoot();

        return true;
    }
497752
public static function open($fileName)
    {
        self::checkRequirements();

        if (!file_exists($fileName) || !is_readable($fileName))
            throw new Exception('Could not open file: '.$fileName);

        $type = self::detectArchiveType($fileName);
        if (!self::canOpenType($type)) {
            return null;
        }

        return new self($fileName, $type);
    }
927335
public function deleteDir($dirname)
    {
        $item = $this->listDirContents($dirname);
        $enties = array_map(function($file) {
            return new \Qiniu_RS_EntryPath($this->bucket, $file['key']);
        }, $item);
        list($ret, $err) = Qiniu_RS_BatchDelete($this->getClient(), $enties);
        return $err === null;
    }
1118762
public function _mkdir($dirName)
    {
        if (is_dir($dirName)) {
            return;
        }

        $success = mkdir($dirName, 0777, true);
        
        if (!$success) {
            throw new ExpectationException("Could not create $path");
        }
    }
671809
public function rmdir(string $dirName): bool
    {
        return unlink($this->fileInfo->getAbsoluteFilePath() . MDir::getSeparator() . $dirName);
    }
140267
public function open($filename)
    {
        if ($this->opened) {
            $this->close();
        }
        $this->indentation = 0;
        $this->buffer->clear();
        $this->filename = $filename;
        $this->opened = true;

        return $this;
    }
301216
public function openFile($filename)
    {
        $this->file = file_get_contents($this->absolutizePath($filename));
        $this->filepath = $filename;
    }
413035
public function mkdir(string $dirName): bool
    {
        return mkdir($this->fileInfo->getAbsoluteFilePath() . MDir::getSeparator() . $dirName);
    }
935977
public function ensureDirectory($dirname)
    {
        $dirname = (string) $dirname;
        if ($dirname !== '' && !$this->has($dirname)) {
            $this->createDir($dirname, []);
        }
    }
730111
protected function assertDirectoryIsWriteable(string $directoryName): void
    {
        if (!is_dir($directoryName) || !is_writable($directoryName)) {
            throw new InvalidPathException(sprintf('Unable to write to the directory at "%s"', $directoryName));
        }
    }
981460
public function deleteDir($dirname)
    {
        return (bool)$this->normalizeResponse(
            Cosapi::delFolder($this->getBucket(), $dirname)
        );
    }
1152880
private function ensuredRemoveDir($dirname)
    {
        try
        {
            $this->fs->deleteDir($dirname);
            return;
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        throw new WriteException("Directory $dirname could not be removed.", 0, $ex);
    }
1354309
private function _findFile(string $dirName, string $fileName): ?FileHandler {
        $dirs = glob($dirName . '*');
        $file = null;
        foreach ($dirs as $d) {
            if (is_file($d)) {
                $pathInfo = \pathinfo($d);
                $pathInfo2 = \pathinfo($fileName);

                if (isset($pathInfo2["extension"])) {
                    $condition = $pathInfo["basename"] === $pathInfo2["basename"];
                } else {
                    $condition = $pathInfo["filename"] === $pathInfo2["filename"];
                }

                if ($condition) {
                    return new FileHandler($dirName . "/" . $pathInfo["basename"]);
                }
            } else if (is_dir($d)) {
                $tmp = $this->_findFile($d . "/", $fileName);
                if (null !== $tmp) {
                    $file = $tmp;
                }
            }
        }
        return $file;
    }
1297754
public function deleteDir($dirname)
    {
        return (bool) $this->normalizeResponse(
            $this->cosApi->delFolder($this->getBucket(), $dirname)
        );
    }