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

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

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

    if (isDir)
    {
      std::shared_ptr<CFileItem> item(new CFileItem(name));
      std::string path(strRoot);

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

  // 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;

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

Review comment (suggestion):
```suggestion
      const auto item = std::make_shared<CFileItem>(name);
```

Code after:

    const auto item = std::make_shared<CFileItem>(name);
    item->SetDateTime(localTime);
    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);