// Creates a musicdb url CStdString CDirectoryNode::BuildPath() const { CStdStringArray array; if (!m_strName.empty()) array.insert(array.begin(), m_strName); CDirectoryNode* pParent=m_pParent; while (pParent!=NULL) { const CStdString& strNodeName=pParent->GetName(); if (!strNodeName.empty()) array.insert(array.begin(), strNodeName); pParent=pParent->GetParent(); } CStdString strPath="musicdb://"; for (int i=0; i<(int)array.size(); ++i) strPath+=array[i]+"/"; string options = m_options.GetOptionsString(); if (!options.empty()) strPath += "?" + options; return strPath; }
// Parses a given path and returns the current node of the path CDirectoryNode* CDirectoryNode::ParseURL(const CStdString& strPath) { CURL url(strPath); CStdString strDirectory=url.GetFileName(); URIUtils::RemoveSlashAtEnd(strDirectory); CStdStringArray Path; StringUtils::SplitString(strDirectory, "/", Path); if (!strDirectory.empty()) Path.insert(Path.begin(), ""); CDirectoryNode* pNode=NULL; CDirectoryNode* pParent=NULL; NODE_TYPE NodeType=NODE_TYPE_ROOT; for (int i=0; i<(int)Path.size(); ++i) { pNode=CDirectoryNode::CreateNode(NodeType, Path[i], pParent); NodeType= pNode ? pNode->GetChildType() : NODE_TYPE_NONE; pParent=pNode; } // Add all the additional URL options to the last node if (pNode) pNode->AddOptions(url.GetOptions()); return pNode; }
// Creates a videodb url CStdString CDirectoryNode::BuildPath() const { CStdStringArray array; if (!m_strName.IsEmpty()) array.insert(array.begin(), m_strName); CDirectoryNode* pParent=m_pParent; while (pParent!=NULL) { const CStdString& strNodeName=pParent->GetName(); if (!strNodeName.IsEmpty()) array.insert(array.begin(), strNodeName); pParent=pParent->GetParent(); } CStdString strPath="videodb://"; for (int i=0; i<(int)array.size(); ++i) strPath+=array[i]+"/"; return strPath; }
void CAdvancedSettings::GetCustomRegexps(TiXmlElement *pRootElement, CStdStringArray& settings) { TiXmlElement *pElement = pRootElement; while (pElement) { int iAction = 0; // overwrite // for backward compatibility const char* szAppend = pElement->Attribute("append"); if ((szAppend && stricmp(szAppend, "yes") == 0)) iAction = 1; // action takes precedence if both attributes exist const char* szAction = pElement->Attribute("action"); if (szAction) { iAction = 0; // overwrite if (stricmp(szAction, "append") == 0) iAction = 1; // append else if (stricmp(szAction, "prepend") == 0) iAction = 2; // prepend } if (iAction == 0) settings.clear(); TiXmlNode* pRegExp = pElement->FirstChild("regexp"); int i = 0; while (pRegExp) { if (pRegExp->FirstChild()) { CStdString regExp = pRegExp->FirstChild()->Value(); regExp.MakeLower(); if (iAction == 2) settings.insert(settings.begin() + i++, 1, regExp); else settings.push_back(regExp); } pRegExp = pRegExp->NextSibling("regexp"); } pElement = pElement->NextSiblingElement(pRootElement->Value()); } }
CStdStringArray URIUtils::SplitPath(const CStdString& strPath) { CURL url(strPath); // silly CStdString can't take a char in the constructor CStdString sep(1, url.GetDirectorySeparator()); // split the filename portion of the URL up into separate dirs CStdStringArray dirs; StringUtils::SplitString(url.GetFileName(), sep, dirs); // we start with the root path CStdString dir = url.GetWithoutFilename(); if (!dir.IsEmpty()) dirs.insert(dirs.begin(), dir); // we don't need empty token on the end if (dirs.size() > 1 && dirs.back().IsEmpty()) dirs.erase(dirs.end() - 1); return dirs; }
void CExternalPlayer::GetCustomRegexpReplacers(TiXmlElement *pRootElement, CStdStringArray& settings) { int iAction = 0; // overwrite // for backward compatibility const char* szAppend = pRootElement->Attribute("append"); if ((szAppend && stricmp(szAppend, "yes") == 0)) iAction = 1; // action takes precedence if both attributes exist const char* szAction = pRootElement->Attribute("action"); if (szAction) { iAction = 0; // overwrite if (stricmp(szAction, "append") == 0) iAction = 1; // append else if (stricmp(szAction, "prepend") == 0) iAction = 2; // prepend } if (iAction == 0) settings.clear(); TiXmlElement* pReplacer = pRootElement->FirstChildElement("replacer"); int i = 0; while (pReplacer) { if (pReplacer->FirstChild()) { const char* szGlobal = pReplacer->Attribute("global"); const char* szStop = pReplacer->Attribute("stop"); bool bGlobal = szGlobal && stricmp(szGlobal, "true") == 0; bool bStop = szStop && stricmp(szStop, "true") == 0; CStdString strMatch; CStdString strPat; CStdString strRep; XMLUtils::GetString(pReplacer,"match",strMatch); XMLUtils::GetString(pReplacer,"pat",strPat); XMLUtils::GetString(pReplacer,"rep",strRep); if (!strPat.IsEmpty() && !strRep.IsEmpty()) { CLog::Log(LOGDEBUG," Registering replacer:"); CLog::Log(LOGDEBUG," Match:[%s] Pattern:[%s] Replacement:[%s]", strMatch.c_str(), strPat.c_str(), strRep.c_str()); CLog::Log(LOGDEBUG," Global:[%s] Stop:[%s]", bGlobal?"true":"false", bStop?"true":"false"); // keep literal commas since we use comma as a seperator strMatch.Replace(",",",,"); strPat.Replace(",",",,"); strRep.Replace(",",",,"); CStdString strReplacer = strMatch + " , " + strPat + " , " + strRep + " , " + (bGlobal ? "g" : "") + (bStop ? "s" : ""); if (iAction == 2) settings.insert(settings.begin() + i++, 1, strReplacer); else settings.push_back(strReplacer); } else { // error message about missing tag if (strPat.IsEmpty()) CLog::Log(LOGERROR," Missing <Pat> tag"); else CLog::Log(LOGERROR," Missing <Rep> tag"); } } pReplacer = pReplacer->NextSiblingElement("replacer"); } }
LibraryLoader* DllLoaderContainer::FindModule(const char* sName, const char* sCurrentDir, bool bLoadSymbols) { if (URIUtils::IsInArchive(sName)) { CURL url(sName); CStdString newName = "special://temp/"; newName += url.GetFileName(); CFile::Cache(sName, newName); return FindModule(newName, sCurrentDir, bLoadSymbols); } if (CURL::IsFullPath(sName)) { // Has a path, just try to load return LoadDll(sName, bLoadSymbols); } #ifdef TARGET_POSIX else if (strcmp(sName, "xbmc.so") == 0) return LoadDll(sName, bLoadSymbols); #endif else if (sCurrentDir) { // in the path of the parent dll? CStdString strPath=sCurrentDir; strPath+=sName; if (CFile::Exists(strPath)) return LoadDll(strPath.c_str(), bLoadSymbols); } // in environment variable? CStdStringArray vecEnv; #if defined(TARGET_ANDROID) CStdString systemLibs = getenv("XBMC_ANDROID_SYSTEM_LIBS"); StringUtils::SplitString(systemLibs, ":", vecEnv); CStdString localLibs = getenv("XBMC_ANDROID_LIBS"); vecEnv.insert(vecEnv.begin(),localLibs); #else StringUtils::SplitString(ENV_PATH, ";", vecEnv); #endif LibraryLoader* pDll = NULL; for (int i=0; i<(int)vecEnv.size(); ++i) { CStdString strPath=vecEnv[i]; URIUtils::AddSlashAtEnd(strPath); #ifdef LOGALL CLog::Log(LOGDEBUG, "Searching for the dll %s in directory %s", sName, strPath.c_str()); #endif strPath+=sName; // Have we already loaded this dll if ((pDll = GetModule(strPath.c_str())) != NULL) return pDll; if (CFile::Exists(strPath)) return LoadDll(strPath.c_str(), bLoadSymbols); } // can't find it in any of our paths - could be a system dll if ((pDll = LoadDll(sName, bLoadSymbols)) != NULL) return pDll; CLog::Log(LOGDEBUG, "Dll %s was not found in path", sName); return NULL; }