00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // License: "Symbian Foundation License v1.0" to Symbian Foundation 00004 // members and "Symbian Foundation End User License Agreement v1.0" 00005 // to non-members at the URL 00006 // "http://www.symbianfoundation.org/legal/licencesv10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // This example, shows how the signature of a resource file is 00015 // checked before it is used. 00016 // 00017 00018 00019 #include "CommonToResourceFilesEx.h" 00020 #include <sigcheck.rsg> // resources 00021 00022 00023 // Do the example 00024 LOCAL_C void doExampleL() 00025 { 00026 _LIT(KFormat,"%S\n"); 00027 00028 // Pointer to a resource file 00029 RResourceFile resourceFile; 00030 // open resource file on the emulator(__WINS__ is defined for the Windows emulator) 00031 //(leave if error) 00032 #if defined(__WINS__) 00033 _LIT(KZSystemDataSigRsc,"Z:\\Resource\\apps\\SigCheck.rsc"); 00034 resourceFile.OpenL(fsSession, KZSystemDataSigRsc); 00035 #endif 00036 00037 // open a resource file on the target phone 00038 // ( __EPOC32__ is defined for all target hardware platforms regardless of processor type/hardware architecture) 00039 #if defined(__EPOC32__) 00040 _LIT(KCSystemDataSigRsc,"Z:\\Resource\\apps\\SigCheck.rsc"); 00041 resourceFile.OpenL(fsSession, KCSystemDataSigRsc); 00042 #endif 00043 // check resource file signature 00044 TInt version=23; // version 023 00045 resourceFile.ConfirmSignatureL(version); 00046 00047 // confirm, and leave if error 00048 // read resource from file 00049 HBufC8* dataBuffer=resourceFile.AllocReadLC(R_BASE_HELLO); 00050 TResourceReader reader; 00051 reader.SetBuffer(dataBuffer); 00052 TPtrC textdata = reader.ReadTPtrC(); 00053 // write string to test console 00054 console->Printf(KFormat, &textdata); 00055 // clean up data buffer 00056 CleanupStack::PopAndDestroy(); // finished with dataBuffer 00057 // close resource file 00058 resourceFile.Close(); // finished with resourceFile 00059 } 00060