HICON GetFileIcon(LPCTSTR szFilePath,BOOL bDir) { std::wstring strExt(L""); if (! bDir) { std::wstring strTmp = szFilePath; std::wstring::size_type dotPos = strTmp.rfind(L'.'); if (dotPos!=std::wstring::npos) { strExt.append(L"*"); strExt.append( strTmp.substr(dotPos,strTmp.length()-dotPos)); } } SHFILEINFO fileInfo = {0}; if ( !SHGetFileInfo(strExt.c_str(), 0, &fileInfo, sizeof(fileInfo), SHGFI_LARGEICON | SHGFI_ICON | SHGFI_USEFILEATTRIBUTES ) ) return NULL; return fileInfo.hIcon; }
void CPlayerView::OnFileOpen() { POSITION pos=NULL; CString strExt( _W( "M3U;PLS;" ) + GetInFileNameExt() ); // create custom open file dialog COpenFileDlg fileDlg( g_config.GetPlayDir(), CUString( strExt ), IDI_FILE_ICON); fileDlg.ShowDelOrigCtrl( FALSE ); fileDlg.ShowNormalizeCtrl( FALSE ); fileDlg.ShowRiffWavCtrl( FALSE ); fileDlg.ShowKeepDirLayoutCtrl( FALSE ); // check if OK button has been pressed if ( IDOK == fileDlg.DoModal() ) { // Save to the config file g_config.SetPlayDir(fileDlg.GetDir()); g_config.Save(); pos = fileDlg.GetStartPosition(); // Obtain the number of files while ( NULL != pos ) { AddToPlayList( CString( fileDlg.GetNextPathName(pos) ) ); } } }
void CPlayerView::OnPlaylistSave() { static TCHAR BASED_CODE szFilter[] = _T( "M3U PlayList (*.m3u)|*.m3u|PLS Playlist (*.pls)|*.pls||" ); CFileDialog dlg( FALSE, _T( "m3u" ), _T( "playlist"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter ); if ( IDOK == dlg.DoModal() ) { unsigned int i = 0; CString strFileName = dlg.GetPathName(); // delete old file FILE* pFile = CDexOpenFile( CUString( strFileName ), _W( "w" ) ); fclose( pFile ); // strip exentention strFileName = strFileName.Left( strFileName.GetLength() - 4 ); CUString cuFileName( strFileName ); PlayList playList( cuFileName ); CString strExt( dlg.GetFileExt() ); strExt.MakeLower(); BOOL bIsPls = strExt == _T( "pls" ); for ( i = 0; i< m_vFileNames.size() ; i++ ) { CString strEntry = m_vFileNames[ i ]; if ( bIsPls ) { playList.AddPLSEntry( CUString( strEntry ) ); } else { playList.AddM3UEntry( CUString( strEntry ) ); } } } }
BOOL ISndStreamWinAmp::OpenStream( const CUString& strFileName ) { DWORD i = 0; BOOL bFound = FALSE; LTRACE2( _T( "ISndStreamWinAmp::OpenStream( %s )" ), strFileName ); int nPos = 0; CUString strExt( _T( "wav" ) ); g_bFinished = FALSE; g_bInitialized = FALSE; g_bOutOpened = FALSE; g_eFinished.ResetEvent(); FlushFIFO( ); nPos = strFileName.ReverseFind('.'); if ( nPos >= 0 ) { strExt = strFileName.Right( strFileName.GetLength() - nPos - 1 ); strExt.MakeLower(); } // Set the buffer size SetBufferSize( 9000 ); SetFileName( strFileName ); int nRet = 0; // loop through the available plugings for ( i=0; i < gs_vWinAmpProps.size(); i++ ) { m_WinAmpProp = gs_vWinAmpProps[i]; // m_WinAmpProp.pModule->Init( ); // check if the module can handle the file format if ( ( nRet = m_WinAmpProp.pModule->IsOurFile( (LPSTR)GetDosFileName( strFileName ) ) ) ) { bFound = TRUE; break; } /* if ( ( 0 == strExt.CompareNoCase( _T( "flac" ) ) ) && ( 0 == strExt.CompareNoCase( m_WinAmpProp.strExt ) ) ) { bFound = TRUE; break; } */ CUString strPluginExt( m_WinAmpProp.pModule->FileExtensions, CP_UTF8 ); strPluginExt.MakeLower(); // check first on extention if ( strPluginExt.Find( strExt ) >=0 ) { bFound = TRUE; break; } // m_WinAmpProp.pModule->Quit( ); } if ( !bFound ) { LTRACE2( _T( "ISndStreamWinAmp::OpenStream Failed, no proper plugin found!" ) ); return FALSE; } if ( 0 == m_WinAmpProp.pModule->UsesOutputPlug ) { LTRACE2( _T( "ISndStreamWinAmp::OpenStream; Failed, does not use Output Plugin " ) ); return FALSE; } LTRACE2( _T( "ISndStreamWinAmp::OpenStream found proper plugin ( %s )" ) , m_WinAmpProp.pModule->description ); // setup proper function calls m_WinAmpProp.pModule->SetInfo = SetInfo; m_WinAmpProp.pModule->SAAddPCMData = SAAddPCMData; m_WinAmpProp.pModule->SAGetMode = SAGetMode; m_WinAmpProp.pModule->SAAdd = SAAdd; m_WinAmpProp.pModule->VSAAddPCMData = VSAAddPCMData; m_WinAmpProp.pModule->VSAGetMode = VSAGetMode; m_WinAmpProp.pModule->VSAAdd = VSAAdd; m_WinAmpProp.pModule->VSASetInfo = VSASetInfo; m_WinAmpProp.pModule->dsp_isactive = dsp_isactive; m_WinAmpProp.pModule->dsp_dosamples = dsp_dosamples; m_WinAmpProp.pModule->EQSet = EQSet; m_WinAmpProp.pModule->SAVSADeInit = WMIN_SAVSADeInit; m_WinAmpProp.pModule->SAVSAInit = WMIN_SAVSAInit; m_WinAmpProp.pModule->outMod = &g_OutModule; g_OutModule.version = OUT_VER; g_OutModule.description = g_lpszOutModuleName; g_OutModule.id = 33; g_OutModule.Config = OutConfig; g_OutModule.About = OutAbout; g_OutModule.Init = OutInit; g_OutModule.Quit = OutQuit; g_OutModule.Open = OutOpen; g_OutModule.Close = OutClose; g_OutModule.Write = OutWrite; g_OutModule.CanWrite = OutCanWrite; g_OutModule.IsPlaying = OutIsPlaying; g_OutModule.Pause = OutPause; g_OutModule.SetVolume = OutSetVolume; g_OutModule.SetPan = OutSetPan; g_OutModule.Flush = OutFlush; g_OutModule.GetOutputTime = OutGetOutputTime; g_OutModule.GetWrittenTime = OutGetWrittenTime; SetChannels( 2 ); SetSampleRate( 44100 ); SetBitRate( 176000 * 8 ); // m_dwSamples=wfInfo.samples; m_dwTotalFileSize = 1000; m_dwCurrentFilePos = 0; // start the decoding thread if ( 0 != m_WinAmpProp.pModule->Play( (LPSTR)GetDosFileName( strFileName ) ) ) { return FALSE; } // Wait till output device has been opened by the // input plugin while ( FALSE == g_bOutOpened ) { ::Sleep( 5 ); } SetChannels( g_nNumChannels ); SetSampleRate( g_nOutSampleRate ); SetBitRate( g_nBitRate ); g_bInitialized = TRUE; // return Success return TRUE; }
void CPlayerView::AddToPlayList( const CString& strFileName ) { CString strExt( strFileName ); CString strDir( strFileName ); CString strCurrentDir; int nPos; nPos = strExt.ReverseFind( '.' ); if ( nPos > 0 ) { strExt = strExt.Mid( nPos + 1 ); } nPos = strDir.ReverseFind( _T( '\\' ) ); if ( nPos > 0 ) { strDir = strDir.Left( nPos ); } char lpszCurDir[ MAX_PATH + 1 ] = {'\0',}; // Get current directory _getcwd( lpszCurDir, sizeof( lpszCurDir ) ); if ( 0 == strExt.CompareNoCase( _T( "M3U" ) ) ) { // go to the directory if ( 0 == _tchdir( strDir ) ) { // open the playlist FILE* pFile = CDexOpenFile( CUString( strFileName ), _W( "rt" ) ); if ( NULL != pFile ) { char lpszLine[ 8192 ] = {'\0',}; // read the lines in the playlist file while ( NULL != fgets( lpszLine, sizeof( lpszLine ), pFile ) ) { if ( '\n' == lpszLine[ strlen( lpszLine ) -1 ] ) { lpszLine[ strlen( lpszLine ) -1 ] = '\0'; } // skip extended info if ( '#' != lpszLine[0] ) { CString strEntry( lpszLine ); int nPos = 0; if ( strDir.Find( _T( ":\\" ) ) < 0 ) { if ( 0 == ( nPos = strEntry.Find( _T( ".\\" ) ) ) ) { strEntry = strDir + strEntry.Mid( 1 ); } else { strEntry = strDir + _T( "\\" ) + strEntry; } } AddStringToPlayList( strEntry ); } } // close the playlist file fclose( pFile ); } } } else if ( 0 == strExt.CompareNoCase( _T( "PLS" ) ) ) { CIni plsIni; int nNumEntries = 0; CString strEntry; CString strNumber; int i = 0; // go to the directory if ( 0 == _tchdir( strDir ) ) { plsIni.SetIniFileName( CUString( strFileName ) ); nNumEntries = plsIni.GetValue( _T( "playlist" ), _T( "NumberOfEntries" ), nNumEntries ); for ( i = 1; i <= nNumEntries; i++ ) { strNumber.Format( _T( "File%d"), i ); strEntry = plsIni.GetValue( CUString( _W( "playlist" ) ), CUString( strNumber ), _W( "" ) ); if ( !strEntry.IsEmpty() ) { int nPos = 0; if ( strDir.Find( _T( ":\\" ) ) < 0 ) { if ( 0 == ( nPos = strEntry.Find( _T( ".\\" ) ) ) ) { strEntry = strDir + strEntry.Mid( 1 ); } else { strEntry = strDir + _T( "\\" ) + strEntry; } } AddStringToPlayList( strEntry ); } } } } else { AddStringToPlayList( strFileName ); } // switch back to the current directory chdir( lpszCurDir ); }
BOOL CFileIdCreator::Export( FILE* fpOut, const CFileIdCreator::SIdInfo& sInfo, UINT nIndent) { if (sInfo.child.size() == 0) { #ifdef _ENABLE_EXPORT_ENUM if (!m_bIsEnum) { m_bIsEnum = TRUE; _PrintWithIndent(fpOut, nIndent, "enum {\n"); } #endif // #ifdef _ENABLE_EXPORT_ENUM // Get file extension izanagi::tool::CString strExt( izanagi::tool::CFileUtility::GetExtension( s_Buf, sizeof(s_Buf), sInfo.str)); // Get file name from path without extension. VRETURN( izanagi::tool::CFileUtility::GetFileNameFromPathWithoutExt( s_Buf, sizeof(s_Buf), sInfo.str)); IZ_PCSTR pszPathWithoutExt = s_Buf; if (strExt.length() > 0) { _PrintWithIndent( fpOut, #ifdef _ENABLE_EXPORT_ENUM nIndent + 1, "%s_%s = %d,\n", #else // #ifdef _ENABLE_EXPORT_ENUM nIndent, "static const IZ_UINT %s_%s = %d;\n", #endif // #ifdef _ENABLE_EXPORT_ENUM pszPathWithoutExt, strExt, sInfo.id); } else { _PrintWithIndent( fpOut, #ifdef _ENABLE_EXPORT_ENUM nIndent + 1, "%s = %d,\n", #else // #ifdef _ENABLE_EXPORT_ENUM nIndent, "static const IZ_UINT %s = %d;\n", #endif // #ifdef _ENABLE_EXPORT_ENUM pszPathWithoutExt, sInfo.id); } } else { _PrintWithIndent( fpOut, nIndent, "class %s {\n", izanagi::tool::CFileUtility::GetFileNameFromPath(sInfo.str)); _PrintWithIndent(fpOut, nIndent, "public:\n"); std::vector<SIdInfo*>::const_iterator it = sInfo.child.begin(); for (; it != sInfo.child.end(); it++) { const CFileIdCreator::SIdInfo* pChildInfo = *it; BOOL result = Export( fpOut, *pChildInfo, nIndent + 1); VRETURN(result); } #ifdef _ENABLE_EXPORT_ENUM if (m_bIsEnum) { m_bIsEnum = FALSE; _PrintWithIndent(fpOut, nIndent + 1, "};\n"); } #endif // #ifdef _ENABLE_EXPORT_ENUM // end of class. _PrintWithIndent(fpOut, nIndent, "};\n"); } return TRUE; }