public function createDirectory($directoryPath, $permissions = 0777)
    {
        $current = '';
        $parts = array_filter(explode('/', $directoryPath));
        foreach ($parts as $part) {
            $current = "$current/$part";
            if (!empty($part) && !file_exists($current)) {
                mkdir($current, $permissions);
                chmod($current, $permissions);
            }
        }
    }