Repository: xbmc/xbmc
File: xbmc/filesystem/NFSDirectory.cpp (C++)

Code before:
  {
    //connect has failed - so try to get the exported filesystems if no path is given to the url
    if (url.GetShareName().empty())
    {
      if (url.GetHostName().empty())
        return GetServerList(items);
      else
      {
        std::string myStrPath(url.Get());
        URIUtils::AddSlashAtEnd(myStrPath); //be sure the dir ends with a slash
        return GetDirectoryFromExportList(myStrPath, items);
      }
    }
    return false;
  }

  struct nfsdir* nfsdir = NULL;
  if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0)
  {
    CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName,
              nfs_get_error(gNfsConnection.GetNfsContext()));
    return false;
  }
  lock.unlock();

  const std::vector<std::string> exclusions = {".", "..", "lost+found"};
  const auto notExcluded = exclusions.end();

  std::string myStrPath(url.Get());
  URIUtils::AddSlashAtEnd(myStrPath);
  URIUtils::AddSlashAtEnd(strDirName);

  std::string resolvedPath;
  std::vector<CFileItemPtr> fileItems;
  struct nfsdirent* dirent = NULL;
  while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != NULL)
  {
    const std::string& strName = dirent->name;

    //resolve symlinks
    //resolve symlink changes dirent and strName
    const bool isSymLink = dirent->type == NF3LNK;
    if (isSymLink && !ResolveSymlink(strDirName, dirent, resolvedPath))
      continue;

    if (std::ranges::find(exclusions, strName) == notExcluded)
    {
      const bool bIsDir = dirent->type == NF3DIR;

      std::string path = isSymLink ? resolvedPath : (myStrPath + strName);
      if (bIsDir)

Review comment (suggestion):
```suggestion
  constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"};
```

Here fits better `std::array` as number of elements is fixed and known at compile time.

Code after:
    //connect has failed - so try to get the exported filesystems if no path is given to the url
    if (url.GetShareName().empty())
    {
      std::vector<CFileItemPtr> fileItems =
          url.GetHostName().empty() ? GetServerList() : GetDirectoryFromExportList(url);
      bool ret = !fileItems.empty();
      items.AddItems(std::move(fileItems));
      return ret;
    }
    return false;
  }

  struct nfsdir* nfsdir = nullptr;
  if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0)
  {
    CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName,
              nfs_get_error(gNfsConnection.GetNfsContext()));
    return false;
  }
  lock.unlock();

  std::string myStrPath(url.Get());
  URIUtils::AddSlashAtEnd(myStrPath);
  URIUtils::AddSlashAtEnd(strDirName);

  std::string resolvedPath;
  std::vector<CFileItemPtr> fileItems;
  struct nfsdirent* dirent = nullptr;
  while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != nullptr)
  {
    const std::string& name = dirent->name;

    //resolve symlinks
    //resolve symlink changes dirent and name
    const bool isSymLink = dirent->type == NF3LNK;
    if (isSymLink && !ResolveSymlink(strDirName, dirent, resolvedPath))
      continue;

    if (name == "." || name == ".." || name == "lost+found")
      continue;

    const bool isDir = dirent->type == NF3DIR;

    std::string path = isSymLink ? resolvedPath : (myStrPath + name);
    if (isDir)
      URIUtils::AddSlashAtEnd(path);

    auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(name));
    item->SetPath(path);
    item->SetDateTime(GetDirEntryTime(dirent));
    item->SetFolder(isDir);