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

Code before:
  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)
        URIUtils::AddSlashAtEnd(path);

      CFileItemPtr& pItem = fileItems.emplace_back(std::make_shared<CFileItem>(strName));
      pItem->SetDateTime(GetDirEntryTime(dirent));
      pItem->SetSize(dirent->size);
      pItem->SetFolder(bIsDir);
      pItem->SetPath(path);
      if (strName[0] == '.')
        pItem->SetProperty("file:hidden", true);
    }
  }
  items.AddItems(fileItems);

  lock.lock();
  nfs_closedir(gNfsConnection.GetNfsContext(), nfsdir); //close the dir
  lock.unlock();
  return true;
}

bool CNFSDirectory::Create(const CURL& url2)
{
  int ret = 0;
  bool success=true;

  std::unique_lock lock(gNfsConnection);
  std::string folderName(url2.Get());
  URIUtils::RemoveSlashAtEnd(folderName);//mkdir fails if a slash is at the end!!!
  CURL url(folderName);

Review comment (suggestion):
Since you are already touching these. Drop the `p` prefix from the variable name. Type prefixing is discouraged

Code after:
  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);
    item->SetSize(dirent->size);

    if (name[0] == '.')
      item->SetProperty("file:hidden", true);
  }
  items.AddItems(std::move(fileItems));

  lock.lock();
  nfs_closedir(gNfsConnection.GetNfsContext(), nfsdir); //close the dir
  lock.unlock();
  return true;
}

bool CNFSDirectory::Create(const CURL& url2)
{
  int ret = 0;
  bool success=true;

  std::unique_lock lock(gNfsConnection);
  std::string folderName(url2.Get());
  URIUtils::RemoveSlashAtEnd(folderName);//mkdir fails if a slash is at the end!!!
  CURL url(folderName);
  folderName = "";

  if(!gNfsConnection.Connect(url,folderName))
    return false;

  ret = nfs_mkdir(gNfsConnection.GetNfsContext(), folderName.c_str());