ronantakizawa/codereview-bench huggingface dataset:
Repository: xbmc/xbmc
File: xbmc/filesystem/BlurayDirectory.cpp (C++)

Code before:
  const std::string& filename = url.GetFileName();
  return CURL(host.append(filename));
}

bool CBlurayDirectory::InitializeBluray(const std::string &root)
{
  bd_set_debug_handler(CBlurayCallback::bluray_logger);
  bd_set_debug_mask(DBG_CRIT | DBG_BLURAY | DBG_NAV);
  std::string real_path = root;

  FindMountPoint(&real_path);

  m_bd = bd_init();

  if (!m_bd)
  {
    CLog::Log(LOGERROR, "CBlurayDirectory::InitializeBluray - failed to initialize libbluray");
    return false;
  }

  std::string langCode;
  g_LangCodeExpander.ConvertToISO6392T(g_langInfo.GetDVDMenuLanguage(), langCode);
  bd_set_player_setting_str(m_bd, BLURAY_PLAYER_SETTING_MENU_LANG, langCode.c_str());

  if (!bd_open_files(m_bd, const_cast<std::string*>(&real_path), CBlurayCallback::dir_open,
                     CBlurayCallback::file_open))
  {
    CLog::Log(LOGERROR, "CBlurayDirectory::InitializeBluray - failed to open {}",
              CURL::GetRedacted(root));
    return false;
  }
  m_blurayInitialized = true;

  return true;
}

std::string CBlurayDirectory::HexToString(const uint8_t *buf, int count)
{
  std::array<char, 42> tmp;

  for (int i = 0; i < count; i++)
  {
    sprintf(tmp.data() + (i * 2), "%02x", buf[i]);
  }

  return std::string(std::begin(tmp), std::end(tmp));
}

std::vector<BLURAY_TITLE_INFO*> CBlurayDirectory::GetUserPlaylists()
{
  std::string root = m_url.GetHostName();

Review comment (suggestion):
With the proposed function signature this could be changed as such:
```cpp
  m_realPath = FindMountPoint(root);
  if (!bd_open_files(m_bd, &m_realPath, CBlurayCallback::dir_open, CBlurayCallback::file_open))
```

Code after:
std::string CBlurayDirectory::HexToString(const uint8_t *buf, int count)
{
  std::array<char, 42> tmp;

  for (int i = 0; i < count; i++)
  {
    sprintf(tmp.data() + (i * 2), "%02x", buf[i]);
  }

  return std::string(std::begin(tmp), std::end(tmp));
}

std::vector<BLURAY_TITLE_INFO*> CBlurayDirectory::GetUserPlaylists()
{
  std::string root = m_url.GetHostName();
  std::string discInfPath = URIUtils::AddFileToFolder(root, "disc.inf");
  std::vector<BLURAY_TITLE_INFO*> userTitles;
  CFile file;
  std::string line;
  line.reserve(1024);

  if (file.Open(discInfPath))
  {
    CLog::Log(LOGDEBUG, "CBlurayDirectory::GetTitles - disc.inf found");

    CRegExp pl(true);
    if (!pl.RegComp("(\\d+)"))
    {
      file.Close();
      return userTitles;
    }

    uint8_t maxLines = 100;
    while ((maxLines > 0) && file.ReadLine(line))
    {
      maxLines--;
      if (StringUtils::StartsWithNoCase(line, "playlists"))
      {
        int pos = 0;
        while ((pos = pl.RegFind(line, static_cast<unsigned int>(pos))) >= 0)
        {
          std::string playlist = pl.GetMatch(0);
          uint32_t len = static_cast<uint32_t>(playlist.length());

          if (len <= 5)
          {
            unsigned long int plNum = strtoul(playlist.c_str(), nullptr, 10);

            BLURAY_TITLE_INFO* t = bd_get_playlist_info(m_bd, static_cast<uint32_t>(plNum), 0);
            if (t)
              userTitles.emplace_back(t);
Repository: xbmc/xbmc
File: xbmc/filesystem/BlurayDirectory.h (C/C++)

Code before:

#pragma once

#include "IDirectory.h"
#include "URL.h"

#include <memory>

class CFileItem;
class CFileItemList;

typedef struct bluray BLURAY;
typedef struct bd_title_info BLURAY_TITLE_INFO;

namespace XFILE
{

class CBlurayDirectory : public IDirectory
{
public:
  CBlurayDirectory() = default;
  ~CBlurayDirectory() override;
  bool GetDirectory(const CURL& url, CFileItemList &items) override;

  bool InitializeBluray(const std::string &root);
  void FindMountPoint(std::string* file);
  std::string GetBlurayTitle();
  std::string GetBlurayID();

private:
  enum class DiscInfo
  {
    TITLE,
    ID
  };

  void         Dispose();
  std::string  GetDiscInfoString(DiscInfo info);
  void         GetRoot  (CFileItemList &items);
  void         GetTitles(bool main, CFileItemList &items);
  std::vector<BLURAY_TITLE_INFO*> GetUserPlaylists();
  std::shared_ptr<CFileItem> GetTitle(const BLURAY_TITLE_INFO* title, const std::string& label);
  CURL         GetUnderlyingCURL(const CURL& url);
  std::string  HexToString(const uint8_t * buf, int count);
  CURL          m_url;
  BLURAY*       m_bd = nullptr;
  bool          m_blurayInitialized = false;
};

}


Review comment (suggestion):
Please move the function to the `private` section.

Code after:

#pragma once

#include "IDirectory.h"
#include "URL.h"

#include <memory>

class CFileItem;
class CFileItemList;

typedef struct bluray BLURAY;
typedef struct bd_title_info BLURAY_TITLE_INFO;

namespace XFILE
{

class CBlurayDirectory : public IDirectory
{
public:
  CBlurayDirectory() = default;
  ~CBlurayDirectory() override;
  bool GetDirectory(const CURL& url, CFileItemList &items) override;

  bool InitializeBluray(const std::string &root);
  std::string GetBlurayTitle();
  std::string GetBlurayID();

private:
  enum class DiscInfo
  {
    TITLE,
    ID
  };

  void         Dispose();
  std::string  GetDiscInfoString(DiscInfo info);
  void         GetRoot  (CFileItemList &items);
  void         GetTitles(bool main, CFileItemList &items);
  std::vector<BLURAY_TITLE_INFO*> GetUserPlaylists();
  std::shared_ptr<CFileItem> GetTitle(const BLURAY_TITLE_INFO* title, const std::string& label);
  CURL         GetUnderlyingCURL(const CURL& url);
  std::string  HexToString(const uint8_t * buf, int count);
  CURL          m_url;
  BLURAY*       m_bd = nullptr;
  bool          m_blurayInitialized = false;
  std::string m_realPath;
};

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

Code before:

  closedir(dir);

  if (success)
  {
    if (rmdir(root.c_str()) != 0)
      success = false;
  }

  return success;
}

bool CPosixDirectory::Exists(const CURL& url)
{
  std::string path = url.Get();

  if (IsAliasShortcut(path, true))
    TranslateAliasShortcut(path);

  struct stat buffer;
  if (stat(path.c_str(), &buffer) != 0)
    return false;
  return S_ISDIR(buffer.st_mode) ? true : false;
}

std::string CPosixDirectory::ResolveMountPoint(const std::string& file)
{
#ifdef HAVE_GETMNTENT_R
  // Check if file is a block device, if yes we need the mount point
  struct stat st;

  if (stat(file.c_str(), &st) == 0 && S_ISBLK(st.st_mode))
  {
    // the path may be a symlink (e.g. /dev/dvd -> /dev/sr0), so make sure
    // we look up the real device
    char pathBuffer[MAX_PATH];
    char* bdDevice = realpath(file.c_str(), pathBuffer);

    if (bdDevice == nullptr)
    {
      CLog::LogF(LOGERROR, "realpath on '{}' failed with {}", file, errno);
      return file;
    }

    struct FileDeleter
    {
      void operator()(FILE* f) { endmntent(f); }
    };
    std::unique_ptr<FILE, FileDeleter> mtab(setmntent("/proc/self/mounts", "r"));

    if (mtab)

Review comment (suggestion):
```suggestion
std::string CPosixDirectory::ResolveMountPoint(const std::string& file) const
```

Code after:

  closedir(dir);

  if (success)
  {
    if (rmdir(root.c_str()) != 0)
      success = false;
  }

  return success;
}

bool CPosixDirectory::Exists(const CURL& url)
{
  std::string path = url.Get();

  if (IsAliasShortcut(path, true))
    TranslateAliasShortcut(path);

  struct stat buffer;
  if (stat(path.c_str(), &buffer) != 0)
    return false;
  return S_ISDIR(buffer.st_mode) ? true : false;
}

std::string CPosixDirectory::ResolveMountPoint(const std::string& file) const
{
#ifdef HAVE_GETMNTENT_R
  // Check if file is a block device, if yes we need the mount point
  struct stat st;

  if (stat(file.c_str(), &st) == 0 && S_ISBLK(st.st_mode))
  {
    // the path may be a symlink (e.g. /dev/dvd -> /dev/sr0), so make sure
    // we look up the real device
    char pathBuffer[MAX_PATH];
    char* bdDevice = realpath(file.c_str(), pathBuffer);

    if (bdDevice == nullptr)
    {
      CLog::LogF(LOGERROR, "realpath on '{}' failed with {}", file, errno);
      return file;
    }

    struct FileDeleter
    {
      void operator()(FILE* f) { endmntent(f); }
    };
    std::unique_ptr<FILE, FileDeleter> mtab(setmntent("/proc/self/mounts", "r"));

    if (mtab)
Repository: xbmc/xbmc
File: xbmc/platform/posix/filesystem/PosixDirectory.h (C/C++)

Code before:
/*
 *  Copyright (C) 2014-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "filesystem/IDirectory.h"

namespace XFILE
{

class CPosixDirectory : public IDirectory
{
public:
  CPosixDirectory(void);
  ~CPosixDirectory(void) override;
  bool GetDirectory(const CURL& url, CFileItemList &items) override;
  bool Create(const CURL& url) override;
  bool Exists(const CURL& url) override;
  bool Remove(const CURL& url) override;
  bool RemoveRecursive(const CURL& url) override;
  std::string ResolveMountPoint(const std::string& file) override;

private:
  bool Create(const std::string& path);
};
}


Review comment (suggestion):
```suggestion
  std::string ResolveMountPoint(const std::string& file) const override;
```

Code after:
/*
 *  Copyright (C) 2014-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "filesystem/IDirectory.h"

namespace XFILE
{

class CPosixDirectory : public IDirectory
{
public:
  CPosixDirectory(void);
  ~CPosixDirectory(void) override;
  bool GetDirectory(const CURL& url, CFileItemList &items) override;
  bool Create(const CURL& url) override;
  bool Exists(const CURL& url) override;
  bool Remove(const CURL& url) override;
  bool RemoveRecursive(const CURL& url) override;
  std::string ResolveMountPoint(const std::string& file) const override;

private:
  bool Create(const std::string& path);
};
}
Repository: xbmc/xbmc
File: xbmc/video/VideoDatabase.h (C/C++)

Code before:
#define VIDEODB_TYPE_UNUSED 0
#define VIDEODB_TYPE_STRING 1
#define VIDEODB_TYPE_INT 2
#define VIDEODB_TYPE_FLOAT 3
#define VIDEODB_TYPE_BOOL 4
#define VIDEODB_TYPE_COUNT 5
#define VIDEODB_TYPE_STRINGARRAY 6
#define VIDEODB_TYPE_DATE 7
#define VIDEODB_TYPE_DATETIME 8

enum class VideoDbContentType
{
  UNKNOWN = -1,
  MOVIES = 1,
  TVSHOWS = 2,
  MUSICVIDEOS = 3,
  EPISODES = 4,
  MOVIE_SETS = 5,
  MUSICALBUMS = 6
};

template<>
struct fmt::formatter<VideoDbContentType> : fmt::formatter<std::string_view>
{
  template<typename FormatContext>
  constexpr auto format(const VideoDbContentType& type, FormatContext& ctx)
  {
    return fmt::formatter<string_view>::format(enumToSV(type), ctx);
  }

private:
  static constexpr std::string_view enumToSV(VideoDbContentType type)
  {
    using namespace std::literals::string_view_literals;
    switch (type)
    {
      case VideoDbContentType::UNKNOWN:
        return "unknown"sv;
      case VideoDbContentType::MOVIES:
        return "movies"sv;
      case VideoDbContentType::TVSHOWS:
        return "TV shows"sv;
      case VideoDbContentType::MUSICVIDEOS:
        return "music videos"sv;
      case VideoDbContentType::EPISODES:
        return "episodes"sv;
      case VideoDbContentType::MOVIE_SETS:
        return "movie sets"sv;
      case VideoDbContentType::MUSICALBUMS:
        return "music albums"sv;
    };

Review comment (suggestion):
For `std::string_view`, `#include <string_view>` should be added.

Code after:
#define VIDEODB_DETAILS_MUSICVIDEO_UNIQUEID_VALUE VIDEODB_MAX_COLUMNS + 12
#define VIDEODB_DETAILS_MUSICVIDEO_UNIQUEID_TYPE VIDEODB_MAX_COLUMNS + 13

#define VIDEODB_TYPE_UNUSED 0
#define VIDEODB_TYPE_STRING 1
#define VIDEODB_TYPE_INT 2
#define VIDEODB_TYPE_FLOAT 3
#define VIDEODB_TYPE_BOOL 4
#define VIDEODB_TYPE_COUNT 5
#define VIDEODB_TYPE_STRINGARRAY 6
#define VIDEODB_TYPE_DATE 7
#define VIDEODB_TYPE_DATETIME 8

enum class VideoDbContentType
{
  UNKNOWN = -1,
  MOVIES = 1,
  TVSHOWS = 2,
  MUSICVIDEOS = 3,
  EPISODES = 4,
  MOVIE_SETS = 5,
  MUSICALBUMS = 6
};

template<>
struct fmt::formatter<VideoDbContentType> : fmt::formatter<std::string_view>
{
  template<typename FormatContext>
  constexpr auto format(const VideoDbContentType& type, FormatContext& ctx)
  {
    return fmt::formatter<std::string_view>::format(enumToSV(type), ctx);
  }

private:
  static constexpr std::string_view enumToSV(VideoDbContentType type)
  {
    using namespace std::literals::string_view_literals;
    switch (type)
    {
      case VideoDbContentType::UNKNOWN:
        return "unknown"sv;
      case VideoDbContentType::MOVIES:
        return "movies"sv;
      case VideoDbContentType::TVSHOWS:
        return "TV shows"sv;
      case VideoDbContentType::MUSICVIDEOS:
        return "music videos"sv;
      case VideoDbContentType::EPISODES:
        return "episodes"sv;
      case VideoDbContentType::MOVIE_SETS:
        return "movie sets"sv;
Repository: xbmc/xbmc
File: xbmc/network/DNSNameCache.h (C/C++)

Code before:
  /*!
   * \brief Get an IP for a hostname from the cache
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info is in the cache, otherwise unchanged
   *
   * \return true if the IP is cached
   */
  static bool GetCached(const std::string& strHostName, std::string& strIpAddress);
  /*!
   * \brief Get the IP for the hostname from the cache or query it form the DNS
   *
   * If a successful DNS query was performed the result is added to the cache for the duration of \ref TTL
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info can be provided, otherwise unchanged
   *
   * \return true if the IP is cached or the DNS query was successful
   */
  static bool Lookup(const std::string& strHostName, std::string& strIpAddress);

private:
  CDNSNameCache() = default;

  static constexpr std::chrono::seconds TTL{60};
  static CDNSNameCache _instance;

  struct CacheEntry
  {
    CacheEntry(std::string ip, std::optional<std::chrono::steady_clock::time_point> expirationTime);

    std::string m_ip;
    std::optional<std::chrono::steady_clock::time_point> m_expirationTime;
  };

  CCriticalSection m_critical;
  std::unordered_map<std::string, CacheEntry> m_hostToIp;
};


Review comment (suggestion):
https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#member-variables

`_instance`-> `ms_instance`

Code after:
  /*!
   * \brief Get an IP for a hostname from the cache
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info is in the cache, otherwise unchanged
   *
   * \return true if the IP is cached
   */
  bool GetCached(const std::string& strHostName, std::string& strIpAddress) const;
  /*!
   * \brief Get the IP for the hostname from the cache or query it form the DNS
   *
   * If a successful DNS query was performed the result is added to the cache for the duration of \ref TTL
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info can be provided, otherwise unchanged
   *
   * \return true if the IP is cached or the DNS query was successful
   */
  bool Lookup(const std::string& strHostName, std::string& strIpAddress);

private:
  static constexpr std::chrono::seconds TTL{60};

  struct CacheEntry
  {
    CacheEntry(std::string ip, std::optional<std::chrono::steady_clock::time_point> expirationTime);

    std::string m_ip;
    std::optional<std::chrono::steady_clock::time_point> m_expirationTime;
  };

  mutable CCriticalSection m_critical;
  mutable std::unordered_map<std::string, CacheEntry> m_hostToIp;
};
Repository: xbmc/xbmc
File: xbmc/network/DNSNameCache.h (C/C++)

Code before:
  /*!
   * \brief Get an IP for a hostname from the cache
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info is in the cache, otherwise unchanged
   *
   * \return true if the IP is cached
   */
  static bool GetCached(const std::string& strHostName, std::string& strIpAddress);
  /*!
   * \brief Get the IP for the hostname from the cache or query it form the DNS
   *
   * If a successful DNS query was performed the result is added to the cache for the duration of \ref TTL
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info can be provided, otherwise unchanged
   *
   * \return true if the IP is cached or the DNS query was successful
   */
  static bool Lookup(const std::string& strHostName, std::string& strIpAddress);

private:
  CDNSNameCache() = default;

  static constexpr std::chrono::seconds TTL{60};
  static CDNSNameCache ms_instance;

  struct CacheEntry
  {
    CacheEntry(std::string ip, std::optional<std::chrono::steady_clock::time_point> expirationTime);

    std::string m_ip;
    std::optional<std::chrono::steady_clock::time_point> m_expirationTime;
  };

  CCriticalSection m_critical;
  std::unordered_map<std::string, CacheEntry> m_hostToIp;
};


Review comment (suggestion):
Shouldn't this rather be a `CServiceBroker` component, to be able to control instance's live time? I thought we agreed not to introduce new globals...

Code after:
  /*!
   * \brief Get an IP for a hostname from the cache
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info is in the cache, otherwise unchanged
   *
   * \return true if the IP is cached
   */
  bool GetCached(const std::string& strHostName, std::string& strIpAddress) const;
  /*!
   * \brief Get the IP for the hostname from the cache or query it form the DNS
   *
   * If a successful DNS query was performed the result is added to the cache for the duration of \ref TTL
   *
   * \param strHostName The hostname to look up
   * \param[out] strIpAddress Contains the IP for the hostname if the info can be provided, otherwise unchanged
   *
   * \return true if the IP is cached or the DNS query was successful
   */
  bool Lookup(const std::string& strHostName, std::string& strIpAddress);

private:
  static constexpr std::chrono::seconds TTL{60};

  struct CacheEntry
  {
    CacheEntry(std::string ip, std::optional<std::chrono::steady_clock::time_point> expirationTime);

    std::string m_ip;
    std::optional<std::chrono::steady_clock::time_point> m_expirationTime;
  };

  mutable CCriticalSection m_critical;
  mutable std::unordered_map<std::string, CacheEntry> m_hostToIp;
};
Repository: xbmc/xbmc
File: xbmc/utils/URIUtils.cpp (C++)

Code before:
    if(!file.empty() && file != strFolder)
    {
      AddSlashAtEnd(file);
      url.SetFileName(file);
      strFolder = url.Get();
    }
    return;
  }

  if (!HasSlashAtEnd(strFolder))
  {
    if (IsDOSPath(strFolder))
      strFolder += '\\';
    else
      strFolder += '/';
  }
}

bool URIUtils::HasSlashAtEnd(const std::string& strFile, bool checkURL /* = false */)
{
  if (strFile.empty()) return false;
  if (checkURL && IsURL(strFile))
  {
    CURL url(strFile);
    const std::string& file = url.GetFileName();
    return file.empty() || HasSlashAtEnd(file, false);
  }
  char kar = strFile.c_str()[strFile.size() - 1];

  if (kar == '/' || kar == '\\')
    return true;

  return false;
}

void URIUtils::RemoveSlashAtEnd(std::string& strFolder)
{
  // performance optimization. pvr guide items are mass objects, uri never has a slash at end, and this method is quite expensive...
  if (IsPVRGuideItem(strFolder))
    return;

  if (IsURL(strFolder))
  {
    CURL url(strFolder);
    std::string file = url.GetFileName();
    if (!file.empty() && file != strFolder)
    {
      RemoveSlashAtEnd(file);
      url.SetFileName(file);
      strFolder = url.Get();
      return;

Review comment (suggestion):
Can't all these methods be moved to DiscUtils? They all seem to be disc related, not really Uri related

Code after:
bool URIUtils::IsNfs(const std::string& strFile)
{
  if (IsStack(strFile))
    return IsNfs(CStackDirectory::GetFirstStackedFile(strFile));

  if (IsSpecial(strFile))
    return IsNfs(CSpecialProtocol::TranslatePath(strFile));

  CURL url(strFile);
  if (HasParentInHostname(url))
    return IsNfs(url.GetHostName());

  return IsProtocol(strFile, "nfs");
}

bool URIUtils::IsVideoDb(const std::string& strFile)
{
  return IsProtocol(strFile, "videodb");
}

bool URIUtils::IsBlurayPath(const std::string& strFile)
{
  return IsProtocol(strFile, "bluray");
}

bool URIUtils::IsOpticalMediaFile(const std::string& file)
{
  return IsBDFile(file) || IsDVDFile(file);
}

bool URIUtils::IsBDFile(const std::string& file)
{
  const std::string fileName{GetFileName(file)};
  return StringUtils::EqualsNoCase(fileName, "index.bdmv") ||
         StringUtils::EqualsNoCase(fileName, "MovieObject.bdmv") ||
         StringUtils::EqualsNoCase(fileName, "INDEX.BDM") ||
         StringUtils::EqualsNoCase(fileName, "MOVIEOBJ.BDM");
}

bool URIUtils::IsDVDFile(const std::string& file)
{
  const std::string fileName{GetFileName(file)};
  return StringUtils::EqualsNoCase(fileName, "video_ts.ifo") ||
         (StringUtils::StartsWithNoCase(fileName, "vts_") &&
          StringUtils::EndsWithNoCase(fileName, "_0.ifo") && fileName.length() == 12);
}

bool URIUtils::IsAndroidApp(const std::string &path)
{
  return IsProtocol(path, "androidapp");
}
Repository: xbmc/xbmc
File: xbmc/Autorun.h (C/C++)

Code before:
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

//  CAutorun   -  Autorun for different Cd Media
//         like DVD Movies or XBOX Games
//
// by Bobbin007 in 2003
//
//
//

#ifdef HAS_OPTICAL_DRIVE

#include <memory>
#include <string>
#include <utility>
#include <vector>

struct IntegerSettingOption;

struct PlayDiscOptions
{
  bool bypassSettings{false};
  bool startFromBeginning{false};
  bool forceSelection{false};
};

namespace XFILE
{
  class IDirectory;
}

class CSetting;

enum class AutoCDAction
{
  NONE = 0,
  PLAY,
  RIP
};

namespace MEDIA_DETECT
{
class CAutorun
{
public:

Review comment (refactor):
Definitions should come after forward declarations. And structs should probably be defined after enums (from type-ish to object-ish). And then probably move this into the `MEDIA_DETECT` namespace.

Code after:
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

//  CAutorun   -  Autorun for different Cd Media
//         like DVD Movies or XBOX Games
//
// by Bobbin007 in 2003
//
//
//

#ifdef HAS_OPTICAL_DRIVE

#include <memory>
#include <string>
#include <utility>
#include <vector>

struct IntegerSettingOption;

namespace XFILE
{
  class IDirectory;
}

class CSetting;

enum class AutoCDAction
{
  NONE = 0,
  PLAY,
  RIP
};

namespace MEDIA_DETECT
{

struct PlayDiscOptions
{
  bool bypassSettings{false};
  bool startFromBeginning{false};
  bool forceSelection{false};
};

class CAutorun
{