Repository: xbmc/xbmc
File: xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp (C++)

Code before:
#include "URL.h"
#include "utils/CharsetConverter.h"
#include "utils/XTimeUtils.h"
#include "utils/log.h"

#include "platform/win32/CharsetConverter.h"
#include "platform/win32/WIN32Util.h"
#include "platform/win32/network/WSDiscoveryWin32.h"

#include <Windows.h>
#include <Winnetwk.h>
#pragma comment(lib, "mpr.lib")

#include <lm.h>
#pragma comment(lib, "Netapi32.lib")

#include <cassert>

using namespace XFILE;

using KODI::PLATFORM::WINDOWS::FromW;

namespace
{

uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData)
{
  return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow;
}

KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& findData)
{
  KODI::TIME::FileTime fileTime{};
  fileTime.lowDateTime = findData.ftLastWriteTime.dwLowDateTime;
  fileTime.highDateTime = findData.ftLastWriteTime.dwHighDateTime;

  KODI::TIME::FileTime localTime{};
  KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime);

  if (KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime) == TRUE)
    return localTime;
  else
  {
    CDateTime dt{item->GetDateTime()};
    dt.SetValid(false);
    return dt;
  }
}

} // Unnamed namespace


Review comment (suggestion):
This method not has much value because only is called from one place and is only one line of code.

Maybe remove and use the code in place or keep but convert to to `inline` method (this removes the overload of calling a function).

Code after:
#include "URL.h"
#include "utils/CharsetConverter.h"
#include "utils/XTimeUtils.h"
#include "utils/log.h"

#include "platform/win32/CharsetConverter.h"
#include "platform/win32/WIN32Util.h"
#include "platform/win32/network/WSDiscoveryWin32.h"

#include <Windows.h>
#include <Winnetwk.h>
#pragma comment(lib, "mpr.lib")

#include <lm.h>
#pragma comment(lib, "Netapi32.lib")

#include <cassert>

using namespace XFILE;

using KODI::PLATFORM::WINDOWS::FromW;
using KODI::TIME::FileTime;

// local helper
static inline bool worthTryToConnect(const DWORD lastErr)
{
  return lastErr != ERROR_FILE_NOT_FOUND      && lastErr != ERROR_BAD_NET_NAME  &&
         lastErr != ERROR_NO_NET_OR_BAD_PATH  && lastErr != ERROR_NO_NETWORK    &&
         lastErr != ERROR_BAD_NETPATH;
}

/**
* Get servers recursively or get shares from specific server
* @param basePathToScanPtr the pointer to start point for scan
* @param urlPrefixForItems path prefix to be putted into list items
* @param items             the list of the collected items
* @param getShares         set to true to get shares, set for false to get servers
* @return true if succeed, false otherwise
*/
static bool localGetNetworkResources(struct _NETRESOURCEW* basePathToScanPtr, const std::string& urlPrefixForItems, CFileItemList& items, bool getShares);
static bool localGetShares(const std::wstring& serverNameToScan, const std::string& urlPrefixForItems, CFileItemList& items);
static bool localGetServers(const std::string& urlPrefixForItems, CFileItemList& items);

// check for empty string, remove trailing slash if any, convert to win32 form
inline static std::wstring prepareWin32SMBDirectoryName(const CURL& url)
{
  assert(url.IsProtocol("smb"));

  if (url.GetHostName().empty() || url.GetShareName().empty())
    return std::wstring(); // can't use win32 standard file API, return empty string