Esempio n. 1
0
CPVRChannel *CPVRChannels::GetByPath(const CStdString &strPath)
{
  CPVRChannels *channels = NULL;
  int iChannelNumber = -1;

  /* get the filename from curl */
  CURL url(strPath);
  CStdString strFileName = url.GetFileName();
  CUtil::RemoveSlashAtEnd(strFileName);

  if (strFileName.Left(16) == "channels/tv/all/")
  {
    strFileName.erase(0,16);
    iChannelNumber = atoi(strFileName.c_str());
    channels = &PVRChannelsTV;
  }
  else if (strFileName.Left(19) == "channels/radio/all/")
  {
    strFileName.erase(0,19);
    iChannelNumber = atoi(strFileName.c_str());
    channels = &PVRChannelsRadio;
  }

  return channels ? channels->GetByChannelNumber(iChannelNumber) : NULL;
}
Esempio n. 2
0
CPVRRecording *CPVRRecordings::GetByPath(CStdString &path)
{
  CPVRRecording *tag = NULL;
  CSingleLock lock(m_critSection);

  CURL url(path);
  CStdString fileName = url.GetFileName();
  URIUtils::RemoveSlashAtEnd(fileName);

  if (fileName.Left(11) == "recordings/")
  {
    fileName.erase(0,11);
    int iClientID = atoi(fileName.c_str());
    fileName.erase(0,6);

    if (fileName.IsEmpty())
      return tag;

    int iClientIndex = atoi(fileName.c_str());

    for (unsigned int iRecordingPtr = 0; iRecordingPtr < size(); iRecordingPtr++)
    {
      CPVRRecording *recording = at(iRecordingPtr);

      if (recording->m_iClientId == iClientID && recording->m_iClientIndex == iClientIndex)
      {
        tag = recording;
        break;
      }
    }
  }

  return tag;
}
Esempio n. 3
0
void CPVRRecording::Update(const CPVRRecording &tag)
{
  m_strRecordingId = tag.m_strRecordingId;
  m_iClientId      = tag.m_iClientId;
  m_strTitle       = tag.m_strTitle;
  m_recordingTime  = tag.m_recordingTime;
  m_duration       = tag.m_duration;
  m_iPriority      = tag.m_iPriority;
  m_iLifetime      = tag.m_iLifetime;
  m_strDirectory   = tag.m_strDirectory;
  m_strPlot        = tag.m_strPlot;
  m_strPlotOutline = tag.m_strPlotOutline;
  m_strStreamURL   = tag.m_strStreamURL;
  m_strChannelName = tag.m_strChannelName;
  m_strGenre       = tag.m_strGenre;

  CStdString strShow;
  strShow.Format("%s - ", g_localizeStrings.Get(20364).c_str());
  if (m_strPlotOutline.Left(strShow.size()).Equals(strShow))
  {
    CStdString strEpisode = m_strPlotOutline;
    CStdString strTitle = m_strDirectory;
    
    int pos = strTitle.ReverseFind('/');
    strTitle.erase(0, pos + 1);
    strEpisode.erase(0, strShow.size());
    m_strTitle.Format("%s - %s", strTitle.c_str(), strEpisode);
    pos = strEpisode.Find('-');
    strEpisode.erase(0, pos + 2);
    m_strPlotOutline = strEpisode;
  }
  UpdatePath();
}
Esempio n. 4
0
CStdString CCDDARipper::GetTrackName(CFileItem *item)
{
  // get track number from "cdda://local/01.cdda"
  int trackNumber = atoi(item->GetPath().substr(13, item->GetPath().size() - 13 - 5).c_str());

  // Format up our ripped file label
  CFileItem destItem(*item);
  destItem.SetLabel("");

  // get track file name format from audiocds.trackpathformat setting,
  // use only format part starting from the last '/'
  CStdString strFormat = CSettings::Get().GetString("audiocds.trackpathformat");
  size_t pos = strFormat.find_last_of("/\\");
  if (pos != std::string::npos)
    strFormat.erase(0, pos+1);

  CLabelFormatter formatter(strFormat, "");
  formatter.FormatLabel(&destItem);

  // grab the label to use it as our ripped filename
  CStdString track = destItem.GetLabel();
  if (track.empty())
    track = StringUtils::Format("%s%02i", "Track-", trackNumber);

  AddonPtr addon;
  CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
  if (addon)
  {
    boost::shared_ptr<CAudioEncoder> enc = boost::static_pointer_cast<CAudioEncoder>(addon);
    track += enc->extension;
  }

  return track;
}
Esempio n. 5
0
static void ParseItem(CFileItem* item, SResources& resources, TiXmlElement* root, const CStdString& path)
{
  for (TiXmlElement* child = root->FirstChildElement(); child; child = child->NextSiblingElement())
  {
    CStdString name = child->Value();
    CStdString xmlns;
    size_t pos = name.find(':');
    if(pos != std::string::npos)
    {
      xmlns = name.substr(0, pos);
      name.erase(0, pos+1);
    }

    if      (xmlns == "media")
      ParseItemMRSS   (item, resources, child, name, xmlns, path);
    else if (xmlns == "itunes")
      ParseItemItunes (item, resources, child, name, xmlns, path);
    else if (xmlns == "voddler")
      ParseItemVoddler(item, resources, child, name, xmlns, path);
    else if (xmlns == "boxee")
      ParseItemBoxee  (item, resources, child, name, xmlns, path);
    else if (xmlns == "zn")
      ParseItemZink   (item, resources, child, name, xmlns, path);
    else if (xmlns == "svtplay")
      ParseItemSVT    (item, resources, child, name, xmlns, path);
    else
      ParseItemRSS    (item, resources, child, name, xmlns, path);
  }
}
Esempio n. 6
0
bool CPVRDatabase::DeleteChannelsFromGroup(const CPVRChannelGroup &group, const vector<int> &channelsToDelete)
{
  bool bDelete(true);
  unsigned int iDeletedChannels(0);
  /* invalid group id */
  if (group.GroupID() <= 0)
  {
    CLog::Log(LOGERROR, "PVR - %s - invalid group id: %d", __FUNCTION__, group.GroupID());
    return false;
  }

  while (iDeletedChannels < channelsToDelete.size())
  {
    CStdString strChannelsToDelete;

    for (unsigned int iChannelPtr = 0; iChannelPtr + iDeletedChannels < channelsToDelete.size() && iChannelPtr < 50; iChannelPtr++)
      strChannelsToDelete += StringUtils::Format(", %d", channelsToDelete.at(iDeletedChannels + iChannelPtr));

    if (!strChannelsToDelete.empty())
    {
      strChannelsToDelete.erase(0, 2);

      Filter filter;
      filter.AppendWhere(PrepareSQL("idGroup = %u", group.GroupID()));
      filter.AppendWhere(PrepareSQL("idChannel IN (%s)", strChannelsToDelete.c_str()));

      bDelete = DeleteValues("map_channelgroups_channels", filter) && bDelete;
    }

    iDeletedChannels += 50;
  }

  return bDelete;
}
Esempio n. 7
0
bool CPVRRecordings::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  bool bSuccess(false);
  CFileItemList files;

  {
    CSingleLock lock(m_critSection);

    CURL url(strPath);
    CStdString strFileName = url.GetFileName();
    URIUtils::RemoveSlashAtEnd(strFileName);

    if (strFileName.Left(10) == "recordings")
    {
      strFileName.erase(0, 10);
      GetSubDirectories(strFileName, &items, true);
      GetContents(strFileName, &files);
      bSuccess = true;
    }
  }

  if(bSuccess)
  {
    for (int i = 0; i < files.Size(); i++)
    {
      CFileItemPtr pFileItem = files.Get(i);
      CFileItemPtr pThumbItem = items.Get(pFileItem->GetPath());
      if (!pThumbItem->HasThumbnail())
        m_thumbLoader.LoadItem(pThumbItem.get());
    }
  }

  return bSuccess;
}
Esempio n. 8
0
void URIUtils::RemoveExtension(CStdString& strFileName)
{
  if(IsURL(strFileName))
  {
    CURL url(strFileName);
    strFileName = url.GetFileName();
    RemoveExtension(strFileName);
    url.SetFileName(strFileName);
    strFileName = url.Get();
    return;
  }

  size_t period = strFileName.find_last_of("./\\");
  if (period != string::npos && strFileName[period] == '.')
  {
    CStdString strExtension = strFileName.substr(period);
    StringUtils::ToLower(strExtension);
    strExtension += "|";

    CStdString strFileMask;
    strFileMask = g_advancedSettings.m_pictureExtensions;
    strFileMask += "|" + g_advancedSettings.m_musicExtensions;
    strFileMask += "|" + g_advancedSettings.m_videoExtensions;
    strFileMask += "|" + g_advancedSettings.m_subtitlesExtensions;
#if defined(TARGET_DARWIN)
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg|.app|.applescript|.workflow";
#else
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg";
#endif
    strFileMask += "|";

    if (strFileMask.find(strExtension) != std::string::npos)
      strFileName.erase(period);
  }
}
Esempio n. 9
0
const CPVRChannel *CPVRChannelGroupsContainer::GetByPath(const CStdString &strPath)
{
  const CPVRChannelGroup *channels = NULL;
  int iChannelIndex(-1);

  /* get the filename from curl */
  CURL url(strPath);
  CStdString strFileName = url.GetFileName();
  URIUtils::RemoveSlashAtEnd(strFileName);

  CStdString strCheckPath;
  for (unsigned int bRadio = 0; bRadio <= 1; bRadio++)
  {
    const CPVRChannelGroups *groups = Get(bRadio == 1);
    for (unsigned int iGroupPtr = 0; iGroupPtr < groups->size(); iGroupPtr++)
    {
      const CPVRChannelGroup *group = groups->at(iGroupPtr);
      strCheckPath.Format("channels/%s/%s/", group->IsRadio() ? "radio" : "tv", group->GroupName().c_str());

      if (strFileName.Left(strCheckPath.length()) == strCheckPath)
      {
        strFileName.erase(0, strCheckPath.length());
        channels = group;
        iChannelIndex = atoi(strFileName.c_str());
        break;
      }
    }
  }

  return channels ? channels->GetByIndex(iChannelIndex) : NULL;
}
Esempio n. 10
0
void StringUtils::JoinString(const CStdStringArray &strings, const CStdString& delimiter, CStdString& result)
{
  result = "";
  for(CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); it++ )
    result += (*it) + delimiter;

  if(result != "")
    result.erase(result.size()-delimiter.size(), delimiter.size());
}
Esempio n. 11
0
bool ASAPCodec::IsSupportedFormat(const CStdString &strExt)
{
  CStdString ext = strExt;
  if (ext[0] == '.')
    ext.erase(0, 1);
  return ext == "sap"
    || ext == "cmc" || ext == "cmr" || ext == "dmc"
    || ext == "mpt" || ext == "mpd" || ext == "rmt"
    || ext == "tmc" || ext == "tm8" || ext == "tm2";
}
Esempio n. 12
0
void CTextSearch::GetAndCutNextTerm(CStdString &strSearchTerm, CStdString &strNextTerm)
{
  CStdString strFindNext(" ");

  if (StringUtils::EndsWith(strSearchTerm, "\""))
  {
    strSearchTerm.erase(0, 1);
    strFindNext = "\"";
  }

  int iNextPos = strSearchTerm.Find(strFindNext);
  if (iNextPos != -1)
  {
    strNextTerm = strSearchTerm.Left(iNextPos);
    strSearchTerm.erase(0, iNextPos + 1);
  }
  else
  {
    strNextTerm = strSearchTerm;
    strSearchTerm.clear();
  }
}
Esempio n. 13
0
CStdString DocProvHelper::ReplaceInvalidFileNameChars(CStdString sString) const
{
	while (true)
	{
		/* TXTEX_IGNORE */ 		int iPos = sString.FindOneOf(_T(":*?\"&<>|"));
		if (iPos==-1)
			break;

		sString.erase(sString.begin()+iPos);
	}

	return sString;
}
Esempio n. 14
0
void URIUtils::GetCommonPath(CStdString& strParent, const CStdString& strPath)
{
  // find the common path of parent and path
  unsigned int j = 1;
  while (j <= min(strParent.size(), strPath.size()) && strnicmp(strParent.c_str(), strPath.c_str(), j) == 0)
    j++;
  strParent.erase(j - 1);
  // they should at least share a / at the end, though for things such as path/cd1 and path/cd2 there won't be
  if (!HasSlashAtEnd(strParent))
  {
    strParent = GetDirectory(strParent);
    AddSlashAtEnd(strParent);
  }
}
Esempio n. 15
0
CStdString CIManTestUtils::GetDocNumFromDocID(CStdString sDocID)
{
	int iSlash = (x64_int_cast)sDocID.rfind(_T('/'));
	if(iSlash == -1)
		return _T("");

	sDocID.resize(iSlash);
	iSlash = (x64_int_cast)sDocID.rfind(_T('/'));
	if(iSlash == -1)
		return _T("");

	sDocID.erase(0, iSlash + 1);
	return sDocID;
}
Esempio n. 16
0
void ff_avutil_log(void* ptr, int level, const char* format, va_list va)
{
  static CStdString buffer;

  AVClass* avc= ptr ? *(AVClass**)ptr : NULL;

  if(level >= AV_LOG_DEBUG && g_advancedSettings.m_logLevel <= LOG_LEVEL_DEBUG_SAMBA)
    return;
  else if(g_advancedSettings.m_logLevel <= LOG_LEVEL_NORMAL)
    return;

  int type;
  switch(level)
  {
    case AV_LOG_INFO   : type = LOGINFO;    break;
    case AV_LOG_ERROR  : type = LOGERROR;   break;
    case AV_LOG_DEBUG  :
    default            : type = LOGDEBUG;   break;
  }

  CStdString message, prefix;
  message.FormatV(format, va);

  prefix = "ffmpeg: ";
  if(avc)
  {
    if(avc->item_name)
      prefix += CStdString("[") + avc->item_name(ptr) + "] ";
    else if(avc->class_name)
      prefix += CStdString("[") + avc->class_name + "] ";
  }

  buffer += message;
  int pos, start = 0;
  while( (pos = buffer.find_first_of('\n', start)) >= 0 )
  {
    if(pos>start)
      CLog::Log(type, "%s%s", prefix.c_str(), buffer.substr(start, pos-start).c_str());
    start = pos+1;
  }
  buffer.erase(0, start);
}
Esempio n. 17
0
void CAdvancedSettings::GetCustomExtensions(TiXmlElement *pRootElement, CStdString& extensions)
{
  CStdString extraExtensions;
  CSettings::GetString(pRootElement,"add",extraExtensions,"");
  if (extraExtensions != "")
    extensions += "|" + extraExtensions;
  CSettings::GetString(pRootElement,"remove",extraExtensions,"");
  if (extraExtensions != "")
  {
    CStdStringArray exts;
    StringUtils::SplitString(extraExtensions,"|",exts);
    for (unsigned int i=0;i<exts.size();++i)
    {
      int iPos = extensions.Find(exts[i]);
      if (iPos == -1)
        continue;
      extensions.erase(iPos,exts[i].size()+1);
    }
  }
}
bool CGUIDialogProfileSettings::OnProfilePath(CStdString &dir, bool isDefault)
{
  VECSOURCES shares;
  CMediaSource share;
  share.strName = "Profiles";
  share.strPath = "special://masterprofile/profiles/";
  shares.push_back(share);
  CStdString strDirectory;
  if (dir.IsEmpty())
    strDirectory = share.strPath;
  else
    strDirectory = URIUtils::AddFileToFolder("special://masterprofile/", dir);
  if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares,g_localizeStrings.Get(657),strDirectory,true))
  {
    dir = strDirectory;
    if (!isDefault)
      dir.erase(0,24);
    return true;
  }
  return false;
}
Esempio n. 19
0
void CService::BuildServiceType()
{
  CStdString str = LibPath();
  CStdString ext;

  size_t p = str.find_last_of('.');
  if (p != string::npos)
    ext = str.substr(p + 1);

#ifdef HAS_PYTHON
  CStdString pythonExt = ADDON_PYTHON_EXT;
  pythonExt.erase(0, 2);
  if ( ext.Equals(pythonExt) )
    m_type = PYTHON;
  else
#endif
  {
    m_type = UNKNOWN;
    CLog::Log(LOGERROR, "ADDON: extension '%s' is not currently supported for service addon", ext.c_str());
  }
}
Esempio n. 20
0
bool CPVRRecordings::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  bool bSuccess(false);

  {
    CSingleLock lock(m_critSection);

    CURL url(strPath);
    CStdString strFileName = url.GetFileName();
    URIUtils::RemoveSlashAtEnd(strFileName);

    if (StringUtils::StartsWith(strFileName, "recordings"))
    {
      strFileName.erase(0, 10);
      GetSubDirectories(strFileName, &items);
      bSuccess = true;
    }
  }

  return bSuccess;
}
Esempio n. 21
0
bool CPVRRecordings::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CSingleLock lock(m_critSection);

  CStdString strBase(strPath);
  URIUtils::RemoveSlashAtEnd(strBase);

  CURL url(strPath);
  CStdString strFileName = url.GetFileName();
  URIUtils::RemoveSlashAtEnd(strFileName);

  if (strFileName.Left(10) == "recordings")
  {
    strFileName.erase(0, 10);
    GetSubDirectories(strFileName, &items, true);

    return true;
  }

  return false;
}
Esempio n. 22
0
/// \brief Build a directory history string
/// \param pItem Item to build the history string from
/// \param strHistoryString History string build as return value
void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, CStdString& strHistoryString)
{
  if (pItem->m_bIsShareOrDrive)
  {
    // We are in the virtual directory

    // History string of the DVD drive
    // must be handel separately
    if (pItem->m_iDriveType == CMediaSource::SOURCE_TYPE_DVD)
    {
      // Remove disc label from item label
      // and use as history string, m_strPath
      // can change for new discs
      CStdString strLabel = pItem->GetLabel();
      size_t nPosOpen = strLabel.find('(');
      size_t nPosClose = strLabel.rfind(')');
      if (nPosOpen != std::string::npos &&
          nPosClose != std::string::npos &&
          nPosClose > nPosOpen)
      {
        strLabel.erase(nPosOpen + 1, (nPosClose) - (nPosOpen + 1));
        strHistoryString = strLabel;
      }
      else
        strHistoryString = strLabel;
    }
    else
    {
      // Other items in virtual directory
      strHistoryString = pItem->GetLabel() + pItem->GetPath();
      URIUtils::RemoveSlashAtEnd(strHistoryString);
    }
  }
  else
  {
    // Normal directory items
    strHistoryString = pItem->GetPath();
    URIUtils::RemoveSlashAtEnd(strHistoryString);
  }
}
Esempio n. 23
0
CFileItemPtr CPVRChannelGroups::GetByPath(const CStdString &strPath) const
{
  // get the filename from curl
  CURL url(strPath);
  CStdString strFileName = url.GetFileName();
  URIUtils::RemoveSlashAtEnd(strFileName);

  CStdString strCheckPath;
  for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++)
  {
    // check if the path matches
    strCheckPath.Format("channels/%s/%s/", (*it)->IsRadio() ? "radio" : "tv", (*it)->GroupName().c_str());
    if (strFileName.Left(strCheckPath.length()) == strCheckPath)
    {
      strFileName.erase(0, strCheckPath.length());
      return (*it)->GetByIndex(atoi(strFileName.c_str()));
    }
  }

  // no match
  CFileItemPtr retVal(new CFileItem);
  return retVal;
}
Esempio n. 24
0
const CStdString CPVRRecordings::GetDirectoryFromPath(const CStdString &strPath, const CStdString &strBase) const
{
  CStdString strReturn;
  CStdString strUsePath = TrimSlashes(strPath);
  CStdString strUseBase = TrimSlashes(strBase);

  /* strip the base or return an empty value if it doesn't fit or match */
  if (!strUseBase.IsEmpty())
  {
    if (strUsePath.GetLength() <= strUseBase.GetLength() || strUsePath.Left(strUseBase.GetLength()) != strUseBase)
      return strReturn;
    strUsePath.erase(0, strUseBase.GetLength());
  }

  /* check for more occurences */
  int iDelimiter = strUsePath.Find('/');
  if (iDelimiter > 0)
    strReturn = strUsePath.Left(iDelimiter);
  else
    strReturn = strUsePath;

  return TrimSlashes(strReturn);
}
Esempio n. 25
0
bool GetToken(CStdString &search, CStdString &key, const char *token, bool begin)
{
	try {

		static int index	= 0;
		static int pos		= 0;

		if( begin ){
			index = 0;
			pos		= 0;
		}

		key.erase();

		if( pos < 0 ){
			return false;
		}
		if( search.empty() ){
			return false;
		}
		// procura o elemento separador
		pos = search.find(token, pos);
		// copia o conteudo anterior ao separador
		key = search.substr(index, pos - index);

		if( pos >= 0 ){
			index = pos;
			index++;
			pos++;
		}

		return true;
	}
	catch(...){
		return false;
	}
}
Esempio n. 26
0
string CMime::GetMimeType(const CURL &url, bool lookup)
{
  
  std::string strMimeType;

  if( url.GetProtocol() == "shout" || url.GetProtocol() == "http" || url.GetProtocol() == "https")
  {
    // If lookup is false, bail out early to leave mime type empty
    if (!lookup)
      return strMimeType;

    CStdString strmime;
    XFILE::CCurlFile::GetMimeType(url, strmime);

    // try to get mime-type again but with an NSPlayer User-Agent
    // in order for server to provide correct mime-type.  Allows us
    // to properly detect an MMS stream
    if (StringUtils::StartsWithNoCase(strmime, "video/x-ms-"))
      XFILE::CCurlFile::GetMimeType(url, strmime, "NSPlayer/11.00.6001.7000");

    // make sure there are no options set in mime-type
    // mime-type can look like "video/x-ms-asf ; charset=utf8"
    size_t i = strmime.find(';');
    if(i != std::string::npos)
      strmime.erase(i, strmime.length() - i);
    StringUtils::Trim(strmime);
    strMimeType = strmime;
  }
  else
    strMimeType = GetMimeType(url.GetFileType());

  // if it's still empty set to an unknown type
  if (strMimeType.empty())
    strMimeType = "application/octet-stream";

  return strMimeType;
}
Esempio n. 27
0
const CStdString CPVRRecordings::GetDirectoryFromPath(const CStdString &strPath, const CStdString &strBase) const
{
  CStdString strReturn;
  CStdString strUsePath = TrimSlashes(strPath);
  CStdString strUseBase = TrimSlashes(strBase);

  /* strip the base or return an empty value if it doesn't fit or match */
  if (!strUseBase.IsEmpty())
  {
    /* adding "/" to make sure that base matches the complete folder name and not only parts of it */
    if (strUsePath.GetLength() <= strUseBase.GetLength() || strUsePath.Left(strUseBase.GetLength() + 1) != strUseBase + "/")
      return strReturn;
    strUsePath.erase(0, strUseBase.GetLength());
  }

  /* check for more occurences */
  int iDelimiter = strUsePath.Find('/');
  if (iDelimiter > 0)
    strReturn = strUsePath.Left(iDelimiter);
  else
    strReturn = strUsePath;

  return TrimSlashes(strReturn);
}
Esempio n. 28
0
void URIUtils::RemoveExtension(CStdString& strFileName)
{
  if(IsURL(strFileName))
  {
    CURL url(strFileName);
    strFileName = url.GetFileName();
    RemoveExtension(strFileName);
    url.SetFileName(strFileName);
    strFileName = url.Get();
    return;
  }

  size_t iPos = strFileName.rfind('.');
  // Extension found
  if (iPos != std::string::npos)
  {
    CStdString strExtension = GetExtension(strFileName);
    StringUtils::ToLower(strExtension);
    strExtension += "|";

    CStdString strFileMask;
    strFileMask = g_advancedSettings.m_pictureExtensions;
    strFileMask += "|" + g_advancedSettings.m_musicExtensions;
    strFileMask += "|" + g_advancedSettings.m_videoExtensions;
    strFileMask += "|" + g_advancedSettings.m_subtitlesExtensions;
#if defined(TARGET_DARWIN)
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg|.app|.applescript|.workflow";
#else
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg";
#endif
    strFileMask += "|";

    if (strFileMask.find(strExtension) != std::string::npos)
      strFileName.erase(iPos);
  }
}
Esempio n. 29
0
const CStdString CPVRRecordings::GetDirectoryFromPath(const CStdString &strPath, const CStdString &strBase) const
{
  CStdString strReturn;
  CStdString strUsePath = TrimSlashes(strPath);
  CStdString strUseBase = TrimSlashes(strBase);

  /* strip the base or return an empty value if it doesn't fit or match */
  if (!strUseBase.empty())
  {
    /* adding "/" to make sure that base matches the complete folder name and not only parts of it */
    if (strUsePath.size() <= strUseBase.size() || !StringUtils::StartsWith(strUsePath, strUseBase + "/"))
      return strReturn;
    strUsePath.erase(0, strUseBase.size());
  }

  /* check for more occurences */
  size_t iDelimiter = strUsePath.find('/');
  if (iDelimiter != std::string::npos && iDelimiter > 0)
    strReturn = strUsePath.substr(0, iDelimiter);
  else
    strReturn = strUsePath;

  return TrimSlashes(strReturn);
}
Esempio n. 30
0
////////////////////////////////////////////////////////////////////////////////////
// Function: ExtractTimeFromIndex()
// Extracts the time information from the index string index, returning it as a value in
// milliseconds.
// Assumed format is:
// MM:SS:FF where MM is minutes, SS seconds, and FF frames (75 frames in a second)
////////////////////////////////////////////////////////////////////////////////////
int CCueDocument::ExtractTimeFromIndex(const CStdString &index)
{
  // Get rid of the index number and any whitespace
  CStdString numberTime = index.Mid(5);
  numberTime.TrimLeft();
  while (!numberTime.IsEmpty())
  {
    if (!isdigit(numberTime[0]))
      break;
    numberTime.erase(0, 1);
  }
  numberTime.TrimLeft();
  // split the resulting string
  CStdStringArray time;
  StringUtils::SplitString(numberTime, ":", time);
  if (time.size() != 3)
    return -1;

  int mins = atoi(time[0].c_str());
  int secs = atoi(time[1].c_str());
  int frames = atoi(time[2].c_str());

  return (mins*60 + secs)*75 + frames;
}