javamanager/javacaptain/extensionplugins/javacertstore/src.s60/metadatafilehandler.cpp
--- a/javamanager/javacaptain/extensionplugins/javacertstore/src.s60/metadatafilehandler.cpp Tue May 11 16:07:20 2010 +0300
+++ b/javamanager/javacaptain/extensionplugins/javacertstore/src.s60/metadatafilehandler.cpp Tue May 25 12:34:19 2010 +0300
@@ -26,66 +26,70 @@
bool JavaCertStoreMetadataFileHandler::writeState(std::string aFilePath, int aState)
{
- int len = aFilePath.size();
- HBufC* filePath = HBufC::NewL(len);
- CleanupStack::PushL(filePath);
- TPtr ptr = filePath->Des();
- TPtr8 ptr8((unsigned char *)aFilePath.c_str(),len);
- ptr8.SetLength(len);
- ptr.Copy(ptr8);
- RFs rFs;
- RFile stateFile;
bool res = false;
- int err = rFs.Connect();
- if (err == KErrNone)
- {
- err = stateFile.Open(rFs, ptr, EFileWrite);
- if (err == KErrNotFound)
- {
- err = stateFile.Create(rFs, ptr, EFileWrite);
- }
+ TRAP_IGNORE(
+ int len = aFilePath.size();
+ HBufC* filePath = HBufC::NewL(len);
+ CleanupStack::PushL(filePath);
+ TPtr ptr = filePath->Des();
+ TPtr8 ptr8((unsigned char *)aFilePath.c_str(),len);
+ ptr8.SetLength(len);
+ ptr.Copy(ptr8);
+ RFs rFs;
+ RFile stateFile;
+ int err = rFs.Connect();
if (err == KErrNone)
{
- CleanupClosePushL(stateFile);
- TPckgBuf<TUint32> state(aState);
- stateFile.Write(0, state);
- CleanupStack::PopAndDestroy(); // state file
- res = true;
+ err = stateFile.Open(rFs, ptr, EFileWrite);
+ if (err == KErrNotFound)
+ {
+ err = stateFile.Create(rFs, ptr, EFileWrite);
+ }
+ if (err == KErrNone)
+ {
+ CleanupClosePushL(stateFile);
+ TPckgBuf<TUint32> state(aState);
+ stateFile.Write(0, state);
+ CleanupStack::PopAndDestroy(); // state file
+ res = true;
+ }
}
- }
- CleanupStack::PopAndDestroy(); // file path
+ CleanupStack::PopAndDestroy(); // file path
+ );
return res;
}
int JavaCertStoreMetadataFileHandler::readState(std::string aFilePath)
{
int state = STATE_UNDEFINED;
- int len = aFilePath.size();
- HBufC* filePath = HBufC::NewL(len);
- CleanupStack::PushL(filePath);
- TPtr ptr = filePath->Des();
- TPtr8 ptr8((unsigned char *)aFilePath.c_str(),len);
- ptr8.SetLength(len);
- ptr.Copy(ptr8);
- RFs rFs;
- RFile stateFile;
- int err = rFs.Connect();
- if (err == KErrNone)
- {
- err = stateFile.Open(rFs, ptr, EFileRead);
+ TRAP_IGNORE(
+ int len = aFilePath.size();
+ HBufC* filePath = HBufC::NewL(len);
+ CleanupStack::PushL(filePath);
+ TPtr ptr = filePath->Des();
+ TPtr8 ptr8((unsigned char *)aFilePath.c_str(),len);
+ ptr8.SetLength(len);
+ ptr.Copy(ptr8);
+ RFs rFs;
+ RFile stateFile;
+ int err = rFs.Connect();
if (err == KErrNone)
{
- CleanupClosePushL(stateFile);
- TPckgBuf<TUint32> tmp;
- err = stateFile.Read(0, tmp);
- CleanupStack::PopAndDestroy(); // state file
+ err = stateFile.Open(rFs, ptr, EFileRead);
if (err == KErrNone)
{
- state = tmp();
+ CleanupClosePushL(stateFile);
+ TPckgBuf<TUint32> tmp;
+ err = stateFile.Read(0, tmp);
+ CleanupStack::PopAndDestroy(); // state file
+ if (err == KErrNone)
+ {
+ state = tmp();
+ }
}
}
- }
- CleanupStack::PopAndDestroy(); // file path
+ CleanupStack::PopAndDestroy(); // file path
+ );
return state;
}