check if a given dir is a valid maildir

@param string $dirname name of dir
@return bool dir is valid maildir
181809
protected function _isMaildir($dirname)
    {
        if (file_exists($dirname . '/new') && !is_dir($dirname . '/new')) {
            return false;
        }
        if (file_exists($dirname . '/tmp') && !is_dir($dirname . '/tmp')) {
            return false;
        }
        return is_dir($dirname . '/cur');
    }
1282229
protected function doCreateDir($dirname, Config $config)
    {
        if ($this->hasDirectory($dirname)) {
            return true;
        }

        if ($this->hasFile($dirname)) {
            return false;
        }

        // Make sure all the sub-directories exist.
        if ( ! $this->doCreateDir(Util::dirname($dirname), $config)) {
            return false;
        }

        $this->storage[$dirname]['type'] = 'dir';
        $this->storage[$dirname]['timestamp'] = $config->get('timestamp', time());

        return true;
    }
1093771
public function deleteDirectory($dirname)
    {
        $dirpath = $this->path() . '/' . $dirname;
        
        if (is_dir($dirpath)) {
            ToolboxºFileTools::emptyDir($dirpath);
        }
    }
102594
private function ensuredEraseDir($dirname)
    {
        try
        {
            $listing = $this->fs->listContents($dirname, false);

            foreach ($listing as $item)
            {
                if ($item['type'] === 'dir')
                {
                    $this->fs->deleteDir($item['path']);
                }
                else
                {
                    $this->fs->delete($item['path']);
                }
            }

            return;
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        throw new WriteException("Directory $dirname could not be erased.", 0, $ex);
    }
1000720
protected function doCreateDir($dirname)
	{
		if ($this->hasDirectory($dirname)) {
			return true;
		}

		if ($this->hasFile($dirname)) {
			return false;
		}

		// Make sure all the sub-directories exist.
		if (!$this->doCreateDir(Util::dirname($dirname))) {
			return false;
		}

		$this->storage[$dirname]['type'] = 'dir';

		return true;
	}
191559
public static function deleteDir(string $dirname) : bool
     {
         if (!is_dir($dirname)) {
             return false;
         }

         // Delete dir
         if (is_dir($dirname)) {
             $ob = scandir($dirname);
             foreach ($ob as $o) {
                 if ($o != '.' && $o != '..') {
                     if (filetype($dirname.'/'.$o) == 'dir') {
                         Filesystem::deleteDir($dirname.'/'.$o);
                     } else {
                         unlink($dirname.'/'.$o);
                     }
                 }
             }
         }

         reset($ob);
         rmdir($dirname);

         return true;
     }
583624
public function files($dirname)
    {
        $dirname = $this->path($dirname);

        $directory_contents = glob($dirname . "/*");

        return array_filter($directory_contents, function ($file) {
            return filetype($file) == "file";
        });
    }
707565
public function isFilePathExistWithFallback($filename)
    {
        $emailPath = $this->getOutputFolder() . DIRECTORY_SEPARATOR . $filename;
        $archivePath = $this->getArchiveFolder() . DIRECTORY_SEPARATOR . $filename;
        return is_file($emailPath) ? true : (is_file($archivePath) ? true : false);
    }
247659
public function addFolder( $dirName )
	{
		if( !file_exists( $dirName ) )
			return FALSE;
		$fileInfo = stat( $dirName );													// Get folder information
		$this->numFolders++;															// Add folder to processed data
		$activeDir				= &$this->folders[];
		$activeDir['name']		= $dirName;
		$activeDir['mode']		= $fileInfo['mode'];
		$activeDir['time']		= $fileInfo['mtime'];
		$activeDir['user_id']	= $fileInfo['uid'];
		$activeDir['group_id']	= $fileInfo['gid'];
#		$activeDir['checksum']	= $checksum;
		return TRUE;
	}
1059571
public function removeFolder( $dirName )
	{
		if( !$this->numFolders )
			return FALSE;
		foreach( $this->folders as $key => $information )
		{
			if( $information['name'] !== $dirName )
				continue;
			$this->numFolders--;
			unset( $this->folders[$key] );
			return TRUE;
		}
	}
481989
public function deleteDir($dirname)
    {
        $dirname = rtrim($dirname, '/').'/';

        if (false === $this->has($dirname)) {
            return false;
        }

        $dirname = $this->applyPathPrefix($dirname);

        $this->bucket->object($dirname)->delete();

        return !$this->bucket->object($dirname)->exists();
    }
1066425
public function files($dirname = '.')
    {
        $listing = $this->listDirectoryContents($dirname);

        return array_values(array_filter($listing, function ($item) {
            return $item['type'] === 'file';
        }));
    }
981460
public function deleteDir($dirname)
    {
        return (bool)$this->normalizeResponse(
            Cosapi::delFolder($this->getBucket(), $dirname)
        );
    }
514794
public function createDir($dirname, Config $config)
    {
        $this->getUpyun()->makeDir(static::normalizerPath($dirname, true));
        return true;
    }
744314
public static function rmdirRecursive($dirName)
    {
        //próba zbadania czy jest plikiem
        try {
            $isFile = is_file($dirName);
        } catch (\Exception $e) {
            return false;
        }
        //zwykły plik
        if ($isFile) {
            //próba usunięcia
            try {
                unlink($dirName);
            } catch (\Exception $e) {
                //prawdopodobnie już usunięty
                return false;
            }
            return true;
        }
        //próba otwarcia katalogu
        try {
            $directoryIterator = new \DirectoryIterator($dirName);
        } catch (\Exception $e) {
            //prawdopodobnie już usunięty
            return false;
        }
        //iteracja po katalogu
        foreach ($directoryIterator as $dir) {
            //katalog .
            if ($dir->isDot()) {
                continue;
            }
            //usunięcie rekurencyjne
            self::rmdirRecursive($dir->getPathname());
        }
        //próba usunięcia pustego katalogu
        try {
            rmdir($dirName);
        } catch (\Exception $e) {
            //prawdopodobnie już usunięty
            return false;
        }
        return true;
    }
421
private function ensureExists($dir)
    {
        if (!is_dir($dir)) {
            mkdir($dir, 0755, true);
        }

        return $this->validatePath($dir);
    }
1297754
public function deleteDir($dirname)
    {
        return (bool) $this->normalizeResponse(
            $this->cosApi->delFolder($this->getBucket(), $dirname)
        );
    }