bool Win32DllLoader::NeedsHooking(const char *dllName) { LibraryLoader *loader = DllLoaderContainer::GetModule(dllName); if (loader) { // may have hooked this already (we can have repeats in the import table) for (unsigned int i = 0; i < m_referencedDlls.size(); i++) { if (loader->GetHModule() == m_referencedDlls[i]) return false; } } CStdStringW strdllNameW; g_charsetConverter.utf8ToW(_P(dllName), strdllNameW, false); HMODULE hModule = GetModuleHandleW(strdllNameW.c_str()); wchar_t filepathW[MAX_PATH]; GetModuleFileNameW(hModule, filepathW, MAX_PATH); CStdString dllPath; g_charsetConverter.wToUTF8(filepathW, dllPath); // compare this filepath with some special directories CStdString xbmcPath = _P("special://xbmc"); CStdString homePath = _P("special://home"); CStdString tempPath = _P("special://temp"); return ((strncmp(xbmcPath.c_str(), dllPath.c_str(), xbmcPath.GetLength()) == 0) || (strncmp(homePath.c_str(), dllPath.c_str(), homePath.GetLength()) == 0) || (strncmp(tempPath.c_str(), dllPath.c_str(), tempPath.GetLength()) == 0)); }
void CDirectoryCache::ClearSubPaths(const CStdString& strPath) { CSingleLock lock (m_cs); CStdString storedPath = _P(strPath); CUtil::RemoveSlashAtEnd(storedPath); ivecCache i = m_vecCache.begin(); for (bool found=false; i != m_vecCache.end(); ) { CDir* dir = *i; printf("Comparing %s to %s (%d characters)\n", dir->m_strPath.c_str(), storedPath.c_str(), storedPath.GetLength()); if (found) { delete dir; i = m_vecCache.erase(i); } else if (strncmp(dir->m_strPath.c_str(), storedPath.c_str(), storedPath.GetLength()) == 0 && dir->m_strPath.size() > storedPath.size()) { delete dir; i = m_vecCache.erase(i); } else { i++; } if (storedPath == dir->m_strPath) found = true; } }
// Splits the string input into pieces delimited by delimiter. // if 2 delimiters are in a row, it will include the empty string between them. // added MaxStrings parameter to restrict the number of returned substrings (like perl and python) int StringUtils::SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results, unsigned int iMaxStrings /* = 0 */) { int iPos = -1; int newPos = -1; int sizeS2 = delimiter.GetLength(); int isize = input.GetLength(); results.clear(); vector<unsigned int> positions; newPos = input.Find (delimiter, 0); if ( newPos < 0 ) { results.push_back(input); return 1; } while ( newPos > iPos ) { positions.push_back(newPos); iPos = newPos; newPos = input.Find (delimiter, iPos + sizeS2); } // numFound is the number of delimiters which is one less // than the number of substrings unsigned int numFound = positions.size(); if (iMaxStrings > 0 && numFound >= iMaxStrings) numFound = iMaxStrings - 1; for ( unsigned int i = 0; i <= numFound; i++ ) { CStdString s; if ( i == 0 ) { if ( i == numFound ) s = input; else s = input.Mid( i, positions[i] ); } else { int offset = positions[i - 1] + sizeS2; if ( offset < isize ) { if ( i == numFound ) s = input.Mid(offset); else if ( i > 0 ) s = input.Mid( positions[i - 1] + sizeS2, positions[i] - positions[i - 1] - sizeS2 ); } } results.push_back(s); } // return the number of substrings return results.size(); }
CStdString DotNetRegistrar::RemoveTrailingSlash(CStdString sText) { if (sText.GetLength() == 0) return _T(""); if (sText[sText.GetLength()-1] == '\\') sText = sText.Left(sText.GetLength()-1); return sText; }
// Splits the string input into pieces delimited by delimiter. // if 2 delimiters are in a row, it will include the empty string between them. int StringUtils::SplitString(const CStdString& input, const CStdString& delimiter, CStdStringArray &results) { int iPos = -1; int newPos = -1; int sizeS2 = delimiter.GetLength(); int isize = input.GetLength(); results.clear(); //CArray positions; vector<unsigned int> positions; newPos = input.Find (delimiter, 0); if ( newPos < 0 ) { results.push_back(input); return 1; } int numFound = 1; while ( newPos > iPos ) { numFound++; positions.push_back(newPos); iPos = newPos; newPos = input.Find (delimiter, iPos + sizeS2); } for ( unsigned int i = 0; i <= positions.size(); i++ ) { CStdString s; if ( i == 0 ) { if (i == positions.size()) s = input; else s = input.Mid( i, positions[i] ); } else { int offset = positions[i - 1] + sizeS2; if ( offset < isize ) { if ( i == positions.size() ) s = input.Mid(offset); else if ( i > 0 ) s = input.Mid( positions[i - 1] + sizeS2, positions[i] - positions[i - 1] - sizeS2 ); } } results.push_back(s); } return numFound; }
bool Codec::Init(const CStdString & strFile, unsigned int filecache) { m_bufferSize = 2048 * sizeof(int16_t) * 50; m_buffer = new char[m_bufferSize]; CStdString uri = URIUtils::GetFileName(strFile); CStdString extension = uri.Right(uri.GetLength() - uri.Find('.') - 1); if (extension.Left(12) == "spotifyradio") { //if its a radiotrack the radionumber and tracknumber is secretly encoded at the end of the extension CStdString trackStr = extension.Right( extension.GetLength() - extension.ReverseFind('#') - 1); Logger::printOut(extension); CStdString radioNumber = extension.Left(uri.Find('#')); Logger::printOut(radioNumber); radioNumber = radioNumber.Right( radioNumber.GetLength() - radioNumber.Find('#') - 1); Logger::printOut("loading codec radio"); RadioHandler::getInstance()->pushToTrack(atoi(radioNumber), atoi(trackStr)); } //we have a non legit extension so remove it manually uri = uri.Left(uri.Find('.')); Logger::printOut("trying to load track:"); Logger::printOut(uri); sp_link *spLink = sp_link_create_from_string(uri); m_currentTrack = sp_link_as_track(spLink); sp_track_add_ref(m_currentTrack); sp_link_release(spLink); m_endOfTrack = false; m_bufferPos = 0; m_startStream = false; m_isPlayerLoaded = false; m_TotalTime = sp_track_duration(m_currentTrack); //prefetch the next track! CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC); int nextSong = g_playlistPlayer.GetNextSong(); if (nextSong >= 0 && nextSong < playlist.size()){ CFileItemPtr song = playlist[nextSong]; if (song != NULL){ CStdString uri = song->GetPath(); if (uri.Left(7).Equals("spotify")){ uri = uri.Left(uri.Find('.')); Logger::printOut("prefetching track:"); Logger::printOut(uri); sp_link *spLink = sp_link_create_from_string(uri); sp_track* track = sp_link_as_track(spLink); sp_session_player_prefetch(getSession(), track); sp_link_release(spLink); } } } return true; }
void XBPyThread::setSource(const CStdString &src) { #ifdef TARGET_WINDOWS CStdString strsrc = src; g_charsetConverter.utf8ToSystem(strsrc); m_source = new char[strsrc.GetLength()+1]; strcpy(m_source, strsrc); #else m_source = new char[src.GetLength()+1]; strcpy(m_source, src); #endif }
bool CPVRRecordings::HasAllRecordingsPathExtension(const CStdString &strDirectory) { CStdString strUseDir = TrimSlashes(strDirectory); CStdString strAllRecordingsPathExtension(PVR_ALL_RECORDINGS_PATH_EXTENSION); if (strUseDir.GetLength() < strAllRecordingsPathExtension.GetLength()) return false; if (strUseDir.GetLength() == strAllRecordingsPathExtension.GetLength()) return strUseDir.Equals(strAllRecordingsPathExtension); return strUseDir.Right(strAllRecordingsPathExtension.GetLength() + 1).Equals("/" + strAllRecordingsPathExtension); }
bool CMarkupSTL::x_SetData( int iPos, const char * szData, int nCDATA ) { // Set data at specified position // if nCDATA==1, set content of element to a CDATA Section CStdString csInsert; // Set data in iPos element if ( ! iPos || m_aPos[iPos].iElemChild ) return false; // Build csInsert from szData based on nCDATA // If CDATA section not valid, use parsed text (PCDATA) instead if ( nCDATA != 0 ) if ( ! x_CreateNode(csInsert, MNT_CDATA_SECTION, szData) ) nCDATA = 0; if ( nCDATA == 0 ) csInsert = x_TextToDoc( szData ); // Decide where to insert int nInsertAt, nReplace; if ( m_aPos[iPos].IsEmptyElement() ) { nInsertAt = m_aPos[iPos].nEndL; nReplace = 1; // Pre-adjust since <NAME/> becomes <NAME>data</NAME> CStdString csTagName = x_GetTagName( iPos ); m_aPos[iPos].nStartR -= 1; m_aPos[iPos].nEndL -= (1 + csTagName.GetLength()); CStdString csFormat; csFormat = _T(">"); csFormat += csInsert; csFormat += _T("</"); csFormat += csTagName; csInsert = csFormat; } else { nInsertAt = m_aPos[iPos].nStartR+1; nReplace = m_aPos[iPos].nEndL - m_aPos[iPos].nStartR - 1; } x_DocChange( nInsertAt, nReplace, csInsert ); int nAdjust = csInsert.GetLength() - nReplace; x_Adjust( iPos, nAdjust ); m_aPos[iPos].AdjustEnd( nAdjust ); MARKUP_SETDEBUGSTATE; return true; }
BOOL CObjectEntry::SetValueStringFormat(CStdString strFormattedValue) { CMmcDataConversion conversion; unsigned __int64 uInt64Value(0); CStdString strValue = _T(""); int iIndex; BOOL oResult(TRUE); //Remove leading text iIndex = strFormattedValue.FindOneOf("0123456789"); if(iIndex != -1) strValue = strFormattedValue.Right(strFormattedValue.GetLength()-iIndex); else strValue = strFormattedValue; //Check Types if(conversion.DecUInt64Str2UInt64(strValue, &uInt64Value, FALSE)) { m_ValueStringFormat = OVF_DEC; oResult = TRUE; } else if(conversion.HexUInt64Str2UInt64(strValue, &uInt64Value, FALSE)) { m_ValueStringFormat = OVF_HEX; oResult = TRUE; } else { m_ValueStringFormat = OVF_DEC; oResult = FALSE; } return oResult; }
CStdString CPVRRecordings::RemoveAllRecordingsPathExtension(const CStdString &strDirectory) { if (!HasAllRecordingsPathExtension(strDirectory)) return strDirectory; return strDirectory.Left(strDirectory.GetLength() - strlen(PVR_ALL_RECORDINGS_PATH_EXTENSION) - 1); }
void CMarkupSTL::x_DocChange( int nLeft, int nReplace, const CStdString& csInsert ) { // Insert csInsert int m_csDoc at nLeft replacing nReplace chars // Do this with only one buffer reallocation if it grows // int nDocLength = m_csDoc.GetLength(); int nInsLength = csInsert.GetLength(); // Make sure nLeft and nReplace are within bounds nLeft = max( 0, min( nLeft, nDocLength ) ); nReplace = max( 0, min( nReplace, nDocLength-nLeft ) ); // Get pointer to buffer with enough room int nNewLength = nInsLength + nDocLength - nReplace; int nBufferLen = nNewLength; _TCHAR* pDoc = m_csDoc.GetBuffer( nBufferLen ); // Move part of old doc that goes after insert if ( nLeft+nReplace < nDocLength ) memmove( &pDoc[nLeft+nInsLength], &pDoc[nLeft+nReplace], (nDocLength-nLeft-nReplace)*sizeof(_TCHAR) ); // Copy insert memcpy( &pDoc[nLeft], csInsert, nInsLength*sizeof(_TCHAR) ); // Release m_csDoc.ReleaseBuffer( nNewLength ); }
void CScraperParser::ReplaceBuffers(CStdString& strDest) { // insert buffers int iIndex; for (int i=MAX_SCRAPER_BUFFERS-1; i>=0; i--) { CStdString temp; iIndex = 0; temp.Format("$$%i",i+1); while ((size_t)(iIndex = strDest.find(temp,iIndex)) != CStdString::npos) // COPIED FROM CStdString WITH THE ADDITION OF $ ESCAPING { strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+temp.GetLength(),m_param[i]); iIndex += m_param[i].length(); } } // insert settings iIndex = 0; while ((size_t)(iIndex = strDest.find("$INFO[",iIndex)) != CStdString::npos) { int iEnd = strDest.Find("]",iIndex); CStdString strInfo = strDest.Mid(iIndex+6,iEnd-iIndex-6); CStdString strReplace; if (m_scraper) strReplace = m_scraper->GetSetting(strInfo); strDest.replace(strDest.begin()+iIndex,strDest.begin()+iEnd+1,strReplace); iIndex += strReplace.length(); } iIndex = 0; while ((size_t)(iIndex = strDest.find("\\n",iIndex)) != CStdString::npos) strDest.replace(strDest.begin()+iIndex,strDest.begin()+iIndex+2,"\n"); }
bool Addon_music_spotify::GetTracks(CFileItemList& items, CStdString& path, CStdString artistName, int albumId) { Logger::printOut("get tracks"); CURL url(path); CStdString uri = url.GetFileNameWithoutPath(); //the path will look something like this "musicdb://2/spotify:artist:0LcJLqbBmaGUft1e9Mm8HV/-1/" //if we are trying to show all tracks for a spotify artist, we cant use the params becouse they are only integers. CURL url2(path.Left(path.GetLength() - 3)); CStdString artist = url2.GetFileNameWithoutPath(); if (uri.Left(13).Equals("spotify:album")) { return getAlbumTracks(items, uri); } else if (artist.Left(14).Equals("spotify:artist")) { return getArtistTracks(items, artist); } else if (uri.Left(16).Equals("spotify:playlist")) { uri.Delete(0, 17); return getPlaylistTracks(items, atoi(uri)); } else if (artist.Left(15).Equals("spotify:toplist")) { return g_spotify->getTopListTracks(items); } else if (uri.Left(13).Equals("spotify:radio")) { return getRadioTracks(items, atoi(uri.Right(1))); } else if (uri.Left(13).Equals("spotify:track")) { return getAlbumTracksFromTrack(items, uri); } else if (albumId == -1) { return getAllTracks(items, artistName); } return true; }
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"); int pos = max(strFormat.ReverseFind('/'), strFormat.ReverseFind('\\')); if (pos != -1) { strFormat = strFormat.Right(strFormat.GetLength() - pos - 1); } CLabelFormatter formatter(strFormat, ""); formatter.FormatLabel(&destItem); // grab the label to use it as our ripped filename CStdString track = destItem.GetLabel(); if (track.IsEmpty()) track.Format("%s%02i", "Track-", trackNumber); track += GetExtension(CSettings::Get().GetInt("audiocds.encoder")); return track; }
bool IsIpAddress(const CStdString& address, bool allowNull) { if (GetIPV6LongForm(address) != _T("")) return true; int segment = 0; int dotcount = 0; for (int i = 0; i < address.GetLength(); ++i) { const TCHAR& c = address[i]; if (c == '.') { if (address[i + 1] == '.') // Disallow multiple dots in a row return false; if (segment > 255) return false; if (!dotcount && !segment && !allowNull) return false; dotcount++; segment = 0; } else if (c < '0' || c > '9') return false; segment = segment * 10 + c - '0'; } if (dotcount != 3) return false; if (segment > 255) return false; return true; }
void XBPyThread::setSource(const CStdString &src) { #ifdef TARGET_WINDOWS CStdString strsrc; if (m_type == 'F') strsrc = CSpecialProtocol::TranslatePath(src); else strsrc = src; g_charsetConverter.utf8ToSystem(strsrc); m_source = new char[strsrc.GetLength()+1]; strcpy(m_source, strsrc); #else if (m_source) delete [] m_source; m_source = new char[src.GetLength()+1]; strcpy(m_source, src); #endif }
int XBPyThread::evalFile(const CStdString &src) { m_type = 'F'; m_source = new char[src.GetLength()+1]; strcpy(m_source, src); Create(); return 0; }
bool CPVRRecordings::IsDirectoryMember(const CStdString &strDirectory, const CStdString &strEntryDirectory, bool bDirectMember /* = true */) const { CStdString strUseDirectory = TrimSlashes(strDirectory); CStdString strUseEntryDirectory = TrimSlashes(strEntryDirectory); return strUseEntryDirectory.Left(strUseDirectory.GetLength()).Equals(strUseDirectory) && (!bDirectMember || strUseEntryDirectory.Equals(strUseDirectory)); }
long CMediaMonitor::parse_AggregateValue(CStdString& strFilepath) { long count = 0; for (int i = 0; i < strFilepath.GetLength(); i++) { count += strFilepath[i]; } return count; }
CStdString FileBaseName(CStdString& path) { CStdString result; int lastSeparatorPosition = path.ReverseFind('/'); if(lastSeparatorPosition == -1) { lastSeparatorPosition = path.ReverseFind('\\'); } if(lastSeparatorPosition != -1 && path.GetLength()>3) { result = path.Right(path.GetLength() - lastSeparatorPosition - 1); } else { result = path; } return result; }
void CPictureInfoTag::GetStringFromArchive(CArchive &ar, char *string, size_t length) { CStdString temp; ar >> temp; length = min((size_t)temp.GetLength(), length - 1); if (!temp.IsEmpty()) memcpy(string, temp.c_str(), length); string[length] = 0; }
CIniFile::CIniFile( const CStdString iniPath ) { Path( iniPath ); caseInsensitive = true; if ( iniPath.GetLength() ){ ReadFile(); } }
void COptionsDlgSelector::OnSwap() { AnalyticsHelper::SendDeltaViewStatistics(_T("DeltaView Event: The Swap button pressed")); CStdString sOriginalDoc; //DS: Double the buffer size because now we have extra descriptive info in the string, //therefore its not just a file path or DMS doc ID in the window text. 151.13 m_cboDocumentOne.GetWindowText(sOriginalDoc.GetBuffer(MAX_PATH*2), MAX_PATH*2); sOriginalDoc.ReleaseBuffer(); CStdString sModifiedDoc = m_multiModifiedDlg.GetModifiedText( 0 ); if (sModifiedDoc.GetLength() == 0 && sOriginalDoc.GetLength() == 0) { return; } m_cboDocumentOne.SetWindowTextW( sModifiedDoc ); m_multiModifiedDlg.SetModifiedText( 0, sOriginalDoc ); }
CStdString CURI::ValidatePath(const CStdString &path) { CStdString result = path; // Don't do any stuff on URLs containing %-characters as we may screw up // URL-encoded (embedded) filenames (like with zip:// & rar://) if (path.Find("://") >= 0 && path.Find('%') >= 0) return result; // check the path for incorrect slashes #ifdef _WIN32 if (CUtil::IsDOSPath(path)) { result.Replace('/', '\\'); // Fixup for double back slashes (but ignore the \\ of unc-paths) for (int x=1; x<result.GetLength()-1; x++) { if (result[x] == '\\' && result[x+1] == '\\') result.Delete(x); } } else if (path.Find("://") >= 0 || path.Find(":\\\\") >= 0) { result.Replace('\\', '/'); // Fixup for double forward slashes(/) but don't touch the :// of URLs for (int x=1; x<result.GetLength()-1; x++) { if (result[x] == '/' && result[x+1] == '/' && result[x-1] != ':') result.Delete(x); } } #else result.Replace('\\', '/'); // Fixup for double forward slashes(/) but don't touch the :// of URLs for (int x=1; x<result.GetLength()-1; x++) { if (result[x] == '/' && result[x+1] == '/' && result[x-1] != ':') result.Delete(x); } #endif return result; }
void CTextureBundleXBT::GetTexturesFromPath(const CStdString &path, std::vector<CStdString> &textures) { if (path.GetLength() > 1 && path[1] == ':') return; if (!m_XBTFReader.IsOpen() && !OpenBundle()) return; CStdString testPath = Normalize(path); CUtil::AddSlashAtEnd(testPath); int testLength = testPath.GetLength(); std::vector<CXBTFFile>& files = m_XBTFReader.GetFiles(); for (size_t i = 0; i < files.size(); i++) { CStdString path = files[i].GetPath(); if (path.Left(testLength).Equals(testPath)) textures.push_back(path); } }
CStdString ImanageDetector::GetInstallDirectory() { CStdString sInstallDir = GetInstallPathFromRegistry(); if (sInstallDir.IsEmpty()) return _T(""); if (sInstallDir.Right(1) == _T("\\")) sInstallDir = sInstallDir.Left(sInstallDir.GetLength() - 1); return sInstallDir; }
int CEnDeCode::SplitStringWithSeparator(const CStdString &strSource , const CStdString &strSeparator , std::vector<CStdString> &strVector , BOOL bIsIncludeEmpty) { CStdString strSourceTemp = strSource ; CStdString strTemp = _T("") ; strVector.clear() ; if ( strSource == _T("") ) { return 0 ; } DWORD dwSeparatorLen = strSeparator.GetLength() ; int nPostion = strSourceTemp.Find(strSeparator) ; if (nPostion == -1) { strVector.push_back(strSourceTemp) ; return strVector.size() ; } while (nPostion != -1) { strTemp = strSourceTemp.Left(nPostion) ; if ( !strTemp.IsEmpty() || bIsIncludeEmpty) { strVector.push_back(strTemp) ; } strSourceTemp.Delete(0 , strTemp.GetLength()+dwSeparatorLen) ; strTemp.Empty(); nPostion = strSourceTemp.Find(strSeparator) ; } if ( !strSourceTemp.IsEmpty() || bIsIncludeEmpty) { strVector.push_back(strSourceTemp) ; } return strVector.size() ; }
void ProcessParsedString (HANDLE hPipe, CStdString *pstr, int nArg) { static CStdString wavName(""); static char streamFile[MAX_PATH]; static InterfaceType itype(UNSPECIFIED); static CACEplayerDlg *hMainWndDlg; static ACESEQ seq; CStdString outStr; double dummy; char buf[MAX_PATH]; DWORD dw; int i, res; if (itype==UNSPECIFIED) { hMainWndDlg = (CACEplayerDlg *) (LONG_PTR)GetWindowLong (hMainDlg, GWL_USERDATA); itype = (InterfaceType)hMainWndDlg->hACEobj[0].param->dwReserved; if (itype==SPRINT) LoadString (hInst, IDS_STREAM_FNAME, buf, sizeof(buf)); else if (itype==L34_CIC3 || itype==L34_CIC4) LoadString (hInst, IDS_STREAM_FNAME2, buf, sizeof(buf)); else MessageBox(hMainDlg, "Check itype", "", MB_OK); FulfillFile(streamFile, hMainWndDlg->AppPath, buf); } if (pstr[0]=="IDENTIFY") { outStr = "SUCCESS ACE_PLAYER"; } else if (pstr[0]=="PREPARE") { //As of Oct-28-2010, level input from the controller is no longer used in the presenter. for (wavName="", i=2; i<nArg; i++) wavName += pstr[i]; // check file names containing blank character res=hMainWndDlg->Prepare(&seq, wavName.c_str(), dummy, outStr); } else if (pstr[0]=="PRESENT") { res = hMainWndDlg->Present(&seq, outStr); } else if (pstr[0]=="SET") { if (!(res = hMainWndDlg->Set(pstr, nArg, outStr))) { MessageBox (hMainDlg, outStr, "", MB_OK); return ; } } else { MessageBox (hMainDlg, "Unknown command", "", MB_OK); } WriteFile (hPipe, outStr.c_str(), outStr.GetLength()+1, &dw, NULL); SendMessage (GetDlgItem(hMainDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM)outStr.c_str()); EditPrintf (GetDlgItem(hPipeLog, IDC_MSG), "(outgoing) %s\r\n", outStr.c_str()); }
bool ReportManager::CleanMetadata(const CStdString& sRating, const CStdString& discoveryXml) { if( !m_pHandler ) return false; try { std::vector<CStdStringW> vDiscoveredElements = discoveryXml.GetLength() == 0 ? m_xmlHandler.GetDiscoveredElements(GetXmlReport()) : m_xmlHandler.GetDiscoveredElements(discoveryXml); if (sRating.CompareNoCase(_T("user_selection")) == 0) return m_pHandler->CleanElements(vDiscoveredElements, true); std::vector<CStdStringW> vElements = m_xmlHandler.GetChildNodes(m_xmlResources.GetRatingsXML(), sRating); std::sort(vDiscoveredElements.begin(), vDiscoveredElements.end()); std::sort(vElements.begin(), vElements.end()); if (vDiscoveredElements.size() > 0) { std::vector<CStdStringW> intersection; std::set_intersection(vDiscoveredElements.begin(), vDiscoveredElements.end(), vElements.begin(), vElements.end(), std::back_inserter(intersection)); m_pHandler->CleanElements(intersection); } else { m_pHandler->CleanElements(vElements); } return true; } catch(_com_error& e) { LOG_WS_ERROR(_T("Clean Metadata Failed")); CStdString sMessage = ( e.Error() == E_INVALIDPASSWORD) ? L"A valid password was not provided." : L"Workshare was unable to clean metadata"; ShowMessage(NULL, sMessage, WsOK, WsDefault, Workshare::Messaging::WsErrorIcon, L"Unable to successfully clean metadata", GetHelpId(), _T(__FILE__), __LINE__, _T(__FUNCTION__)); return false; } catch(...) { LOG_WS_ERROR(_T("Clean Metadata Failed")); ShowMessage(NULL, L"Workshare was unable to clean metadata", WsOK, WsDefault, Workshare::Messaging::WsErrorIcon, L"Unable to successfully clean metadata", GetHelpId(), _T(__FILE__), __LINE__, _T(__FUNCTION__)); return false; } }