Repository: xbmc/xbmc
File: xbmc/utils/URIUtils.cpp (C++)

Code before:
    return GetParentPath(parent); // go back up another one
  return parent;
}

std::string URIUtils::GetDiscBasePath(const std::string& file)
{
  std::string base{GetDiscBase(file)};
  if (IsDiscImage(base))
    return GetDirectory(base);
  return base;
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    CURL url(path);
    CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    if (url.IsProtocol("bluray"))
      // BDMV
      return url2.Get() + "BDMV/index.bdmv";
  }
  return path;
}

std::string URLEncodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Encode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URLDecodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Decode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */)
{
  std::string toFile = fromFile;

  // Convert back slashes to forward slashes, if required

Review comment (suggestion):
I think this method should return an empty string if item has no bluray path. The name of the method implies this, if I understand the code correctly.

Code after:
  parentFolder = GetFileName(parentFolder);
  if (StringUtils::EqualsNoCase(parentFolder, "VIDEO_TS") ||
      StringUtils::EqualsNoCase(parentFolder, "BDMV"))
    return GetParentPath(parent); // go back up another one
  return parent;
}

std::string URIUtils::GetDiscBasePath(const std::string& file)
{
  std::string base{GetDiscBase(file)};
  if (IsDiscImage(base))
    return GetDirectory(base);
  return base;
}

std::string URIUtils::GetBlurayFile(const std::string& path)
{
  if (IsBlurayPath(path))
  {
    const CURL url(path);
    const CURL url2(url.GetHostName()); // strip bluray://
    if (url2.IsProtocol("udf"))
      // ISO
      return url2.GetHostName(); // strip udf://
    return AddFileToFolder(url2.Get(), "BDMV", "index.bdmv"); // BDMV
  }
  return std::string{};
}

std::string URLEncodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Encode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URLDecodePath(const std::string& strPath)
{
  std::vector<std::string> segments = StringUtils::Split(strPath, "/");
  for (std::vector<std::string>::iterator i = segments.begin(); i != segments.end(); ++i)
    *i = CURL::Decode(*i);

  return StringUtils::Join(segments, "/");
}

std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */)
{
  std::string toFile = fromFile;