Repository: xbmc/xbmc
File: xbmc/platform/posix/filesystem/SMBDirectory.cpp (C++)

Code before:
      if (lTimeDate == 0) // if modification date is missing, use create date
        lTimeDate = st.st_ctime;
      iSize = st.st_size;
    }

    KODI::TIME::FileTime fileTime, localTime;
    KODI::TIME::TimeTToFileTime(lTimeDate, &fileTime);
    KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime);

    if (bIsDir)
    {
      CFileItemPtr pItem(new CFileItem(strFile));
      std::string path(strRoot);

      path = URIUtils::AddFileToFolder(path, fi->name);
      URIUtils::AddSlashAtEnd(path);
      pItem->SetPath(path);
      pItem->SetFolder(true);
      pItem->SetDateTime(localTime);
      if (hidden)
        pItem->SetProperty("file:hidden", true);
      items.Add(pItem);
    }
    else
    {
      CFileItemPtr pItem(new CFileItem(strFile));
      pItem->SetPath(strRoot + fi->name);
      pItem->SetFolder(false);
      pItem->SetSize(iSize);
      pItem->SetDateTime(localTime);
      if (hidden)
        pItem->SetProperty("file:hidden", true);
      items.Add(pItem);
    }
  }

  // No results from smbc_readdirplus2() suggests server or share browsing.
  // Use smbclient's legacy API for this.
  if (!atLeastOneEntry)
  {
    smbc_lseekdir(fd, 0);

    struct smbc_dirent* dirent;
    while ((dirent = smbc_readdir(fd)))
    {
      if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER)
        continue;

      CFileItemPtr pItem(new CFileItem(dirent->name));
      std::string path(strRoot);
      // needed for network / workgroup browsing

Review comment (suggestion):
Instead of the legacy typedef use the real type `std::make_shared<CFileItem>`

Code after:
    if (hidden)
      item->SetProperty("file:hidden", true);
    if (isDir)
    {
      std::string path(strRoot);

      path = URIUtils::AddFileToFolder(path, name);
      URIUtils::AddSlashAtEnd(path);
      item->SetPath(path);
      item->SetFolder(true);
    }
    else
    {
      item->SetPath(strRoot + name);
      item->SetFolder(false);
      item->SetSize(size);
    }
    items.Add(item);
  }

  // No results from smbc_readdirplus2() suggests server or share browsing.
  // Use smbclient's legacy API for this.
  if (!atLeastOneEntry)
  {
    if (smbc_lseekdir(fd, 0) < 0)
    {
      CLog::LogF(LOGERROR, "Unable to seek directory : '{}'\nunix_err:'{:x}' error: '{}'",
                 CURL::GetRedacted(strAuth), errno, strerror(errno));
      return false;
    }

    struct smbc_dirent* dirent;
    while ((dirent = smbc_readdir(fd)))
    {
      if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER)
        continue;

      const auto item = std::make_shared<CFileItem>(dirent->name);
      std::string path(strRoot);
      // needed for network / workgroup browsing
      // skip if root if we are given a server
      if (dirent->smbc_type == SMBC_SERVER)
      {
        /* create url with same options, user, pass.. but no filename or host*/
        CURL rooturl(strRoot);
        rooturl.SetFileName("");
        rooturl.SetHostName("");
        path = smb.URLEncode(rooturl);
      }
      path = URIUtils::AddFileToFolder(path, dirent->name);
      URIUtils::AddSlashAtEnd(path);