Repository: xbmc/xbmc
File: xbmc/filesystem/BlurayDirectory.cpp (C++)

Code before:

    path.SetFileName(URIUtils::AddFileToFolder(m_url.GetFileName(), "titles"));
    item = std::make_shared<CFileItem>();
    item->SetPath(path.Get());
    item->m_bIsFolder = true;
    item->SetLabel(g_localizeStrings.Get(25002) /* All titles */);
    item->SetArt("icon", "DefaultVideoPlaylists.png");
    items.Add(item);

    const BLURAY_DISC_INFO* disc_info = bd_get_disc_info(m_bd);
    if (disc_info && disc_info->no_menu_support)
    {
      CLog::Log(LOGDEBUG, "CBlurayDirectory::GetRoot - no menu support, skipping menu entry");
      return;
    }

    path.SetFileName("menu");
    item = std::make_shared<CFileItem>();
    item->SetPath(path.Get());
    item->m_bIsFolder = false;
    item->SetLabel(g_localizeStrings.Get(25003) /* Menus */);
    item->SetArt("icon", "DefaultProgram.png");
    items.Add(item);
}

void CBlurayDirectory::FindMountPoint(std::string* file)
{
#ifdef HAVE_GETMNTENT_R
  const char* device = file->c_str();

  /* bd path may be a symlink (e.g. /dev/dvd -> /dev/sr0), so make sure
   * we look up the real device
   */
  char* bd_device = realpath(device, NULL);
  if (bd_device == NULL)
    return;

  struct stat st;
  if (lstat(bd_device, &st) == 0 && S_ISBLK(st.st_mode))
  {
    FILE* mtab = setmntent("/proc/self/mounts", "r");
    if (mtab)
    {
      struct mntent *m, mbuf;
      char buf[8192];

      while ((m = getmntent_r(mtab, &mbuf, buf, sizeof(buf))) != NULL)
      {
        if (!strcmp(m->mnt_fsname, bd_device))
        {
          *file = std::string(strdup(m->mnt_dir));

Review comment (suggestion):
This is specific to Linux. Wouldn't it be possible to move to the base directory and somehow implement it only on Linux? Other implementations would return file 

Code after:
    item = std::make_shared<CFileItem>();
    item->SetPath(path.Get());
    item->m_bIsFolder = true;
    item->SetLabel(g_localizeStrings.Get(25002) /* All titles */);
    item->SetArt("icon", "DefaultVideoPlaylists.png");
    items.Add(item);

    const BLURAY_DISC_INFO* disc_info = bd_get_disc_info(m_bd);
    if (disc_info && disc_info->no_menu_support)
    {
      CLog::Log(LOGDEBUG, "CBlurayDirectory::GetRoot - no menu support, skipping menu entry");
      return;
    }

    path.SetFileName("menu");
    item = std::make_shared<CFileItem>();
    item->SetPath(path.Get());
    item->m_bIsFolder = false;
    item->SetLabel(g_localizeStrings.Get(25003) /* Menus */);
    item->SetArt("icon", "DefaultProgram.png");
    items.Add(item);
}

bool CBlurayDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
  Dispose();
  m_url = url;
  std::string root = m_url.GetHostName();
  std::string file = m_url.GetFileName();
  URIUtils::RemoveSlashAtEnd(file);
  URIUtils::RemoveSlashAtEnd(root);

  if (!InitializeBluray(root))
    return false;

  if(file == "root")
    GetRoot(items);
  else if(file == "root/titles")
    GetTitles(false, items);
  else
  {
    CURL url2 = GetUnderlyingCURL(url);
    CDirectory::CHints hints;
    hints.flags = m_flags;
    if (!CDirectory::GetDirectory(url2, items, hints))
      return false;

    // Found items will have underlying protocol (eg. udf:// or smb://)
    // in path so add back bluray://
    // (so properly recognised in cache as bluray:// files for CFile:Exists() etc..)
    CURL url3{url};