private function extractDirectories(string $path) : array
    {
        $remoteDirs = [];
        if (!empty($path)) {
            $remoteDirs = explode('/', $path);
            // fix empty first array element for absolute path
            if (substr($path, 0, 1) === '/') {
                $remoteDirs[0] = '/';
            }
            $remoteDirs = array_filter($remoteDirs);
        }
        return $remoteDirs;
    }