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

Code before:
    int64_t size = 0;
    const bool isDir = S_ISDIR(st.st_mode);
    int64_t timeDate = 0;
    bool hidden = StringUtils::StartsWith(name, ".");

    // only stat files that can give proper responses
    if (S_ISREG(st.st_mode) || isDir)
    {
      nstats++;
      // This is also present in stuct stat using S_IXOTH but given the potential for confusion
      // let's be explicit.
      hidden = hidden || fi->attrs & SMBC_DOS_MODE_HIDDEN;

      timeDate = st.st_mtime;
      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.

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

Code after:
    {
      // This is also present in stuct stat using S_IXOTH but given the potential for confusion
      // let's be explicit.
      hidden = hidden || fi->attrs & SMBC_DOS_MODE_HIDDEN;

      timeDate = st.st_mtime;
      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);

    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)))
    {