예제 #1
0
void CURL::GetURLWithoutFilename(CStdString& strURL) const
{
  unsigned int sizeneed = m_strProtocol.length()
                        + m_strDomain.length()
                        + m_strUserName.length()
                        + m_strPassword.length()
                        + m_strHostName.length()
                        + 10;

  if( strURL.capacity() < sizeneed )
    strURL.reserve(sizeneed);


  if (m_strProtocol == "")
  {
#ifdef _LINUX
    strURL.Empty();
#else
    strURL = m_strFileName.substr(0, 2); // only copy 'e:'
#endif
    return ;
  }

  strURL = m_strProtocol;
  strURL += "://";

  if (m_strDomain != "")
  {
    strURL += m_strDomain;
    strURL += ";";
  }
  else if (m_strUserName != "")
  {
    strURL += URLEncodeInline(m_strUserName);
    if (m_strPassword != "")
    {
      strURL += ":";
      strURL += URLEncodeInline(m_strPassword);
    }
    strURL += "@";
  }
  else if (m_strDomain != "")
    strURL += "@";

  if (m_strHostName != "")
  {
    if( m_strProtocol.Equals("rar") || m_strProtocol.Equals("zip") || m_strProtocol.Equals("musicsearch"))
      strURL += URLEncodeInline(m_strHostName);
    else
      strURL += m_strHostName;
    if (HasPort())
    {
      CStdString strPort;
      strPort.Format("%i", m_iPort);
      strURL += ":";
      strURL += strPort;
    }
    strURL += "/";
  }
}
예제 #2
0
void CURL::GetURL(CStdString& strURL) const
{
  unsigned int sizeneed = m_strProtocol.length()
                        + m_strDomain.length()
                        + m_strUserName.length()
                        + m_strPassword.length()
                        + m_strHostName.length()
                        + m_strFileName.length()
                        + m_strOptions.length()
                        + 10;

  if( strURL.capacity() < sizeneed )
    strURL.reserve(sizeneed);

  if (m_strProtocol == "")
  {
    strURL = m_strFileName;
    return ;
  }
  GetURLWithoutFilename(strURL);
  strURL += m_strFileName;

  if( m_strOptions.length() > 0 )
    strURL += m_strOptions;
}
예제 #3
0
void CURL::GetURLWithoutUserDetails(CStdString& strURL) const
{
  if (m_strProtocol.Equals("stack"))
  {
    CFileItemList items;
    CStdString strURL2;
    GetURL(strURL2);
    DIRECTORY::CStackDirectory dir;
    dir.GetDirectory(strURL2,items);
    vector<CStdString> newItems;
    for (int i=0;i<items.Size();++i)
    {
      CURL url(items[i]->m_strPath);
      url.GetURLWithoutUserDetails(items[i]->m_strPath);
      newItems.push_back(items[i]->m_strPath);
    }
    dir.ConstructStackPath(newItems,strURL);
    return;
  }

  unsigned int sizeneed = m_strProtocol.length()
                        + m_strDomain.length()
                        + m_strHostName.length()
                        + m_strFileName.length()
                        + m_strOptions.length()
                        + 10;

  if( strURL.capacity() < sizeneed )
    strURL.reserve(sizeneed);


  if (m_strProtocol == "")
  {
    strURL = m_strFileName;
    return ;
  }

  strURL = m_strProtocol;
  strURL += "://";

  if (m_strHostName != "")
  {
    if (m_strProtocol.Equals("rar") || m_strProtocol.Equals("zip"))
    {
      CURL url2(m_strHostName);
      CStdString strHost;
      url2.GetURLWithoutUserDetails(strHost);
      strURL += strHost;
    }
    else
      strURL += m_strHostName;

    if ( HasPort() )
    {
      CStdString strPort;
      strPort.Format("%i", m_iPort);
      strURL += ":";
      strURL += strPort;
    }
    strURL += "/";
  }
  strURL += m_strFileName;

  if( m_strOptions.length() > 0 )
    strURL += m_strOptions;
}