Repository: xbmc/xbmc
File: xbmc/Util.cpp (C++)

Code before:
std::string CUtil::GetFrameworksPath(bool forPython)
{
  std::string strFrameworksPath;
#if defined(TARGET_DARWIN)
  strFrameworksPath = CDarwinUtils::GetFrameworkPath(forPython);
#endif
  return strFrameworksPath;
}

void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath,
                                        std::string& basePath,
                                        std::string& videoFileName)
{
  CFileItem item(videoPath, false);

  if (item.IsOpticalMediaFile() || URIUtils::IsBluray(item.GetDynPath()))
  {
    basePath = item.GetLocalMetadataPath();
    videoFileName = URIUtils::ReplaceExtension(GetTitleFromPath(basePath), "");
  }
  else
  {
    videoFileName = URIUtils::ReplaceExtension(URIUtils::GetFileName(videoPath), "");

    if (item.HasVideoInfoTag())
      basePath = item.GetVideoInfoTag()->m_basePath;

    if (basePath.empty())
      basePath = URIUtils::GetBasePath(videoPath);
  }
}

void CUtil::GetItemsToScan(const std::string& videoPath,
                           const std::string& item_exts,
                           const std::vector<std::string>& sub_dirs,
                           CFileItemList& items)
{
  int flags = DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO;

  if (!videoPath.empty())
    CDirectory::GetDirectory(videoPath, items, item_exts, flags);

  std::vector<std::string> additionalPaths;
  for (const auto &item : items)
  {
    for (const auto& subdir : sub_dirs)
    {
      if (StringUtils::EqualsNoCase(item->GetLabel(), subdir))
        additionalPaths.push_back(item->GetPath());
    }
  }

Review comment (suggestion):
problem carried over from master code: unnecessary because a new CFileItem doesn't have a populated videoinfotag. That makes the following if (basePath.empty()) unnecessary as well.

Code after:
#if defined(TARGET_DARWIN)
  strFrameworksPath = CDarwinUtils::GetFrameworkPath(forPython);
#endif
  return strFrameworksPath;
}

void CUtil::GetVideoBasePathAndFileName(const std::string& videoPath,
                                        std::string& basePath,
                                        std::string& videoFileName)
{
  const CFileItem item(videoPath, false);

  if (item.IsOpticalMediaFile() || URIUtils::IsBlurayPath(item.GetDynPath()))
  {
    basePath = item.GetLocalMetadataPath();
    videoFileName = URIUtils::ReplaceExtension(GetTitleFromPath(basePath), "");
  }
  else
  {
    videoFileName = URIUtils::ReplaceExtension(URIUtils::GetFileName(videoPath), "");
    basePath = URIUtils::GetBasePath(videoPath);
  }
}

void CUtil::GetItemsToScan(const std::string& videoPath,
                           const std::string& item_exts,
                           const std::vector<std::string>& sub_dirs,
                           CFileItemList& items)
{
  int flags = DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO;

  if (!videoPath.empty())
    CDirectory::GetDirectory(videoPath, items, item_exts, flags);

  std::vector<std::string> additionalPaths;
  for (const auto &item : items)
  {
    for (const auto& subdir : sub_dirs)
    {
      if (StringUtils::EqualsNoCase(item->GetLabel(), subdir))
        additionalPaths.push_back(item->GetPath());
    }
  }

  for (std::vector<std::string>::const_iterator it = additionalPaths.begin(); it != additionalPaths.end(); ++it)
  {
    CFileItemList moreItems;
    CDirectory::GetDirectory(*it, moreItems, item_exts, flags);
    items.Append(moreItems);
  }
}