Example #1
0
CUString COpenFileDlg::GetSubPath( POSITION pos ) 
{

	if ( !m_bKeepDirLayout )
	{
		return _T( "" );
	}

	CUString strRet = GetNextPathName( pos );

	int nStartPos = strRet.Find( m_strDir );
	int nLength = strRet.ReverseFind( _T( '\\' ) ) + 1;

	if ( nStartPos >= 0 )
	{
		nStartPos += 1 + m_strDir.GetLength();
	}

	nLength -= nStartPos;

	if ( nLength < 0 )
	{
		nLength = 0;
	}

	strRet = strRet.Mid( nStartPos, nLength );

	return strRet;
}
Example #2
0
CUString COpenFileDlg::GetFileName( POSITION pos ) 
{
	CUString strRet = GetNextPathName( pos );

	int nPos = strRet.ReverseFind('\\');

	if ( nPos >= 0 )
	{
		strRet = strRet.Mid( nPos + 1 );
	}


	return strRet;
}
Example #3
0
bool CDecoder::LoadFoundation( CUOption* option )
{
	if( option == NULL )	return false;
	this->option = option;

	// check options
	CUString key="foundation";
	CUString foundation_dn;
	if( option->GetValue( key, foundation_dn ) == false ) { fprintf( stderr, "Required option is not defined: foundation\n" ); return false; }
	this->foundation_dn = foundation_dn;

	char fn[1024];
	sprintf( fn ,"%s/pair.utf8", foundation_dn.GetStr() );

	CUTextFile file( fn, "r" );
	if( file.CheckOpen() == false )	return false;

	CUString content;
	file.LoadToStr( content );
	CUStringListRO content_list( content, "\n" );
	if( content_list.GetSize() < 4 )	{ fprintf( stderr, "Error: Invalid pair.utf\n" ); return false; }

	src_org = content_list.GetAt(0);
	tgt_org = content_list.GetAt(1);
	src_tok = content_list.GetAt(2);
	tgt_tok = content_list.GetAt(3);

	// load trans tree
	CUStringListRO src_tok_list( src_tok, " " );
	trans_tree.Set( src_tok_list );
	for( int i=4; i<content_list.GetSize(); i++ ) {
		CUString str = content_list.GetAt(i);
		if( str.Find( "S-P\t") == 0 ) {
			CUStringListRO tmp_list( str.Mid(4), ":" );
			if( trans_tree.ApplyParse( tmp_list ) == false ) {
				fprintf( stderr, "Error: Invalid parse rule: %s\n", str.GetStr() );
				return false;
			}
			else {
				//trans_tree.Print( stderr );
			}
		}
	}

	// apply trans rule 
	for( int i=4; i<content_list.GetSize(); i++ ) {
		CUString str = content_list.GetAt(i);
		if( str.Find( "TR\t") == 0 ) {
			CUStringListRO tmp_list( str.Mid(3), "\t" );
			if( trans_tree.ApplyTransRule( tmp_list ) == false ) {
				fprintf( stderr, "Error: Invalid parse rule: %s\n", str.GetStr() );
				return false;
			}
			else {
				//trans_tree.Print( stderr );
			}
		}
	}

	// apply trans rule 
	for( int i=4; i<content_list.GetSize(); i++ ) {
		CUString str = content_list.GetAt(i);
		if( str.Find( "TL\t") == 0 ) {
			CUStringListRO tmp_list( str.Mid(3), "\t" );
			if( trans_tree.ApplyTransLexical( tmp_list ) == false ) {
				fprintf( stderr, "Error: Invalid parse lexical: %s\n", str.GetStr() );
				return false;
			}
			else {
				//trans_tree.Print( stderr );
			}
		}
	}

	trans_tree.OrderByTrans();
	trans_tree.Print( stderr );
	CUString trans_str = trans_tree.GetTransStr();

	CUStringListRO tmp1( tgt_tok, " " );
	fprintf( stderr, "TGT: " );
	for( int i=0; i<tmp1.GetSize(); i++ ) {
		CUString tmp = tmp1.GetAt(i);
		fprintf( stderr, " %s", tmp.Left( tmp.ReverseFind('/') ).GetStr() );
	}
	fprintf( stderr, "\n" );

	CUStringListRO tmp2( trans_str, " " );
	fprintf( stderr, "OUT: " );
	for( int i=0; i<tmp2.GetSize(); i++ ) {
		CUString tmp = tmp2.GetAt(i);
		fprintf( stderr, " %s", tmp.Left( tmp.ReverseFind('/') ).GetStr() );
	}
	fprintf( stderr, "\n" );


	return true;
}
Example #4
0
void COpenFileDlg::AddRecursiveFiles( const CUString& strDir,int nItem )
{
	CFileFind	fileFind;
	CUString		pathAndFileType = strDir + CUString( _W( "\\*.*" ));
	BOOL		bStop=FALSE;

    CUStringConvert strCnv;

	// Iterate through the items in the listbox and populate the listconrol.
	if (fileFind.FindFile( strCnv.ToT( pathAndFileType ) ) )
	{
		do
		{
			bStop=(fileFind.FindNextFile()==0);
			CUString strFileName = CUString( fileFind.GetFileName() );
			CUString strFileRoot = CUString( fileFind.GetRoot() );
			CUString strFileType;

			if (	TRUE == fileFind.IsDirectory() && 
					FALSE == fileFind.IsDots() &&
					TRUE == m_bRecursiveDir )
			{
				AddRecursiveFiles( strDir + CUString( _W( "\\" ) ) + strFileName, nItem );
			}

			if (fileFind.IsDirectory()==FALSE && fileFind.IsDots()==FALSE)
			{
				int nPos=strFileName.ReverseFind( _T( '.' ) );
				

				if (nPos>0)
				{
					CUString strExt;
					strExt = strFileName.Right(strFileName.GetLength()-nPos-1);

					strFileType = strExt;

					strExt.MakeUpper();

					if ( CompareExt( strExt ) == TRUE )
					{
						CUString strFileSize;
						CUString strFileDate;
						CTime	fileTime;

						// Get the data/time stamp of this file
						fileFind.GetLastWriteTime( fileTime );

						// Format date time string
						strFileDate.Format( _W( "%4d/%02d/%02d %02d:%02d" ), fileTime.GetYear(), fileTime.GetMonth(), fileTime.GetDay(), fileTime.GetHour(), fileTime.GetMinute() );

						strFileSize.Format( _W( "%10.2f" ), fileFind.GetLength() / ( 1024.0 * 1024.0 ) );

                        CUStringConvert strCnv;

						m_ctrlRequestedFiles.InsertItem( nItem, strCnv.ToT( strFileName ));

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_TYPE, strCnv.ToT( strFileType ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_DATE ,strCnv.ToT( strFileDate ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_PATH, strCnv.ToT( strFileRoot ) );

						m_ctrlRequestedFiles.SetItemText( nItem, FILE_OPEN_SIZE, strCnv.ToT( strFileSize ) );

						m_ctrlRequestedFiles.SetItemData( nItem, (DWORD)fileTime.GetTime() );

						nItem++;
					}
				}
			}
		} while (bStop!=TRUE);
	}	


	m_bSortAscending=TRUE;
}
Example #5
0
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;
}