Repository: xbmc/xbmc
File: xbmc/storage/MediaManager.cpp (C++)

Code before:
  {
    CLog::Log(LOGDEBUG, "GetDiskUniqueId: Retrieving ID for path {} failed, ID is empty.",
              CURL::GetRedacted(mediaPath));
    return "";
  }

  std::string strID{StringUtils::Format("removable://{}_{}", info.name, info.serial)};
  if (info.type == UTILS::DISCS::DiscType::BLURAY)
  {
    CURL url("bluray://");
    url.SetHostName(strID);
    url.SetFileName(URIUtils::AddFileToFolder("BDMV", "index.bdmv"));
    strID = url.Get();
  }
  CLog::Log(LOGDEBUG, "GetDiskUniqueId: Got ID {} for disc with path {}", strID,
            CURL::GetRedacted(mediaPath));

  return strID;
}

bool CMediaManager::HasMediaBlurayPlaylist(const std::string& devicePath)
{
#ifdef HAVE_LIBBLURAY
  const std::string mediaPath{TranslateDevicePath(devicePath)};
  if (UTILS::DISCS::DiscInfo info{GetDiscInfo(mediaPath)};
      !info.empty() && info.type == UTILS::DISCS::DiscType::BLURAY)
  {
    const std::string blurayPath{GetDiskUniqueId()};
    CVideoDatabase db;
    if (db.Open())
    {
      const std::string path{db.GetRemovableBlurayPath(blurayPath)};
      db.Close();
      return !path.empty();
    }
  }
#endif
  return false;
}

std::string CMediaManager::GetDiscPath()
{
#ifdef TARGET_WINDOWS
  return CServiceBroker::GetMediaManager().TranslateDevicePath("");
#else

  std::unique_lock<CCriticalSection> lock(m_CritSecStorageProvider);
  std::vector<CMediaSource> drives;
  m_platformStorage->GetRemovableDrives(drives);
  for(unsigned i = 0; i < drives.size(); ++i)
  {

Review comment (suggestion):
I didn't even know it was possible to use a semicolon in an if condition 🙂  For code clarity it would be better to not be "tricky" and code in a way that makes it the most readable. Expected code is easier to read than unexpected code.

Code after:
  if (info.empty())
  {
    CLog::Log(LOGDEBUG, "GetDiskUniqueId: Retrieving ID for path {} failed, ID is empty.",
              CURL::GetRedacted(mediaPath));
    return "";
  }

  std::string strID{StringUtils::Format("removable://{}_{}", info.name, info.serial)};
  if (info.type == UTILS::DISCS::DiscType::BLURAY)
  {
    CURL url("bluray://");
    url.SetHostName(strID);
    url.SetFileName(URIUtils::AddFileToFolder("BDMV", "index.bdmv"));
    strID = url.Get();
  }
  CLog::Log(LOGDEBUG, "GetDiskUniqueId: Got ID {} for disc with path {}", strID,
            CURL::GetRedacted(mediaPath));

  return strID;
}

bool CMediaManager::HasMediaBlurayPlaylist(const std::string& devicePath)
{
#ifdef HAVE_LIBBLURAY
  const std::string mediaPath{TranslateDevicePath(devicePath)};
  UTILS::DISCS::DiscInfo info{GetDiscInfo(mediaPath)};
  if (!info.empty() && info.type == UTILS::DISCS::DiscType::BLURAY)
  {
    const std::string blurayPath{GetDiskUniqueId()};
    CVideoDatabase db;
    if (db.Open())
    {
      const std::string path{db.GetRemovableBlurayPath(blurayPath)};
      db.Close();
      return !path.empty();
    }
  }
#endif
  return false;
}

std::string CMediaManager::GetDiscPath()
{
#ifdef TARGET_WINDOWS
  return CServiceBroker::GetMediaManager().TranslateDevicePath("");
#else

  std::unique_lock<CCriticalSection> lock(m_CritSecStorageProvider);
  std::vector<CMediaSource> drives;
  m_platformStorage->GetRemovableDrives(drives);
  for(unsigned i = 0; i < drives.size(); ++i)