int CGenreTable::SearchGenre( CUString strSearch ) const { int i; strSearch.TrimLeft(); strSearch.TrimRight(); for ( i = 0 ; i < (int)v_Entries.size(); i++ ) { if ( 0 == strSearch.CompareNoCase( GetGenre( i ) ) ) { return i; } } return -1; }
void BuildFileName( CUString strFormat, CUString strArray[NUMFILENAME_IDS], CUString& strName,CUString& strDir) { CUString strTmp( strFormat ); int nPos = 0; int i; for ( i=0; i<NUMFILENAME_IDS; i++ ) { strArray[i] = FixFileNameString( strArray[i] ); } // loop through all the tokens while ( (( nPos = strTmp.Find( _T( '%' ),nPos ) ) >=0 ) && ( nPos + 1 < strTmp.GetLength() ) ) { ENUM_FILENAME_CONVERTS convertType = FILENAME_CONVERT_NONE; int nPercentID = 0; int nSkipChars = 2; WCHAR chEval = strTmp.GetAt( nPos + 1 ); if ( _W( 'l' ) == chEval ) { convertType = FILENAME_CONVERT_LOWER; chEval = strTmp.GetAt( nPos + 2 ); nSkipChars++; } if ( _W( 'u' ) == chEval ) { convertType = FILENAME_CONVERT_UPPER; chEval = strTmp.GetAt( nPos + 2 ); nSkipChars++; } if ( _W( 'c' ) == chEval ) { convertType = FILENAME_CONVERT_FCEW_UPPER; chEval = strTmp.GetAt( nPos + 2 ); nSkipChars++; } if ( _W( 'f' ) == chEval ) { convertType = FILENAME_CONVERT_FC_UPPER; chEval = strTmp.GetAt( nPos + 2 ); nSkipChars++; } // Get %ID number switch ( chEval ) { case '1': nPercentID = 0; break; case '2': nPercentID = 1; break; case '3': nPercentID = 2; break; case '4': nPercentID = 3; break; case '5': nPercentID = 4; break; case '6': nPercentID = 5; break; case '7': nPercentID = 6; break; case '8': nPercentID = 7; break; case 'Y': nPercentID = 8; break; case 'G': nPercentID = 9; break; case 'A': nPercentID = 10; break; default: nPercentID = -1; nPos++; break; } if ( nPercentID >= 0 && nPercentID < NUMFILENAME_IDS ) { CUString strLeft( strTmp.Left( nPos ) ); CUString strMid( strArray[ nPercentID ] ); CUString strRight( strTmp.Right( strTmp.GetLength() - nPos - nSkipChars ) ); // do filename mangling strMid = FormatTrackNameString( strMid, convertType ); strTmp = strLeft + strMid + strRight; } else { // Delete token // strTmp = strTmp.Left( nPos ) + strTmp.Right( strTmp.GetLength() - nPos - 1 ); } } // Split result in a directory and file name portion // Search for last backslash nPos = strTmp.ReverseFind( _T( '\\' ) ); if ( nPos >= 2 ) { // OK, we've found the backsplash, do the split strDir = strTmp.Left( nPos + 1 ); strName = strTmp.Right( strTmp.GetLength() - nPos - 1 ); } else { // Only a filename, just assign the string to the filename and clear the directory strDir = _T( "" ); strName = strTmp; } strDir.TrimLeft(); strDir.TrimRight(); // remove spaces before the directory separator and double backslashes INT nIndex = 0; while ( nIndex < strDir.GetLength() ) { if ( _T( '\\' ) == strDir[ nIndex ] ) { if ( nIndex > 0 ) { if ( ( _T( '\\' ) == strDir[ nIndex - 1 ] ) || ( _T( ' ' ) == strDir[ nIndex - 1 ] )) { strDir = strDir.Left( nIndex ) + strDir.Mid( nIndex + 1 ); nIndex = 0; continue; } } } if ( _T( ' ' ) == strDir[ nIndex ] ) { if ( nIndex > 0 ) { if ( ( _T( '\\' ) == strDir[ nIndex - 1 ] ) ) { strDir = strDir.Left( nIndex ) + strDir.Mid( nIndex + 1 ); nIndex = 0; continue; } } } nIndex++; } strDir.TrimLeft(); strDir.TrimRight(); strName.TrimLeft(); strName.TrimRight(); }