|
|
|
To convert an entire file or stream in a single step, use
CConverterBase2::ConvertL() and
CConverterBase2::ConvertObjectL() respectively.
The following code fragment converts the contents of
c:\private\12345678\file1 and places the output in
c:\private\12345678\file2.
_LIT(KFromFile, "c:\\private\\12345678\\file1");
_LIT(KToFile, "c:\\private\\12345678\\file2");
converter->ConvertL(KFromFile, KToFile, NULL);As the conversion process can take a long time, it can be useful to divide the process into multiple steps. To do this,
call CConverterBase2::ConvertAL() (files) or
CConverterBase2::ConvertObjectAL() (streams) to prepare
the converter to convert
call CConverterBase2::DoConvertL() until it
returns true.
The following example converts the contents of
c:\private\12345678\file1 and places the output in
c:\private\12345678\file2 in multiple steps. It assumes that
conversion takes place within an active object, CMyActive, which
does a conversion step in the RunL() function and reactivates the
object if conversion is not complete.
void CMyActive::StartConverting()
{
_LIT(KFromFile, "c:\\private\\12345678\\file1");
_LIT(KToFile, "c:\\private\\12345678\\file2");
converter->ConvertAL(KFromFile, KToFile, NULL);
User::RequestComplete(iStatus,KErrNone);
SetActive();
}
void CMyActive::RunL()
{
if (DoConvertL())
{
User::RequestComplete(iStatus,KErrNone);
SetActive();
}
else
{
// Handle completed conversion
}
}