Symbian
Symbian OS Library

FAQ-0872 My CFileMan code appears to hang - why?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Active Objects
Created: 05/02/2003 Modified: 08/06/2003
Number: FAQ-0872
Platform: Not Applicable

Question:
I'm using a CFileMan object but my code is hanging - why?

Answer:
Most asynchronous requests in Symbian OS are void, and success/failure is indicated by completing the request and examining the result in a TRequestStatus. CFileMan is different, in that the original request function can return an error without starting the asynchronous request. So code like this is essentially wrong:

TRequestStatus stat;
fman->Copy(...., stat, ...);
User::WaitForRequest(stat);

because if Copy() returns an error the wait will be indefinite. The code should in fact be something like:

TRequestStatus stat;
TInt err = fman->Copy(...., stat, ...);
if (err == KErrNone )
{
User::WaitForRequest(stat);
err = stat.Int();
}
else
{
// Take appropriate action
}
return err;

This applies to all the asynchronous functions in CFileMan.