First public contribution.
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "ShiftedFileStore.h"
20 CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset) method.
21 CFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[])
22 method was used as an origin for the method's source code.
24 CShiftedFileStore* CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset)
27 User::LeaveIfError(file.Open(aFs, aName, aFileMode));
28 CShiftedFileStore* store = FromL(file, aFileOffset);
29 CleanupStack::PushL(store);
35 CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset) method.
36 CFileStore::FromL(RFile& aFile,TFileStoreFactoryFunction aFunction) method was used as an origin
37 for the method's source code. The only difference is that RFileBuf::Attach is called with possibly
38 non-zero offset. The original implementation always calls RFileBuf::Attach with zero offset.
40 CShiftedFileStore* CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset)
42 if (static_cast<TInt>(aFileOffset) < 0)
43 User::Leave(KErrArgument);
45 buf.Attach(aFile, static_cast <TInt> (aFileOffset));
47 RReadStream stream(&buf);
50 CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType());
52 User::Leave(KErrNotSupported);
53 //CleanupStack::Pop(2) is called, because:
54 //1) buf.PushL() - actually MStreamBuf::PushL() is called and it pushes buf
56 //1) CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType()) -
57 // FileStoreFactory::DirectLC() is called.
59 return static_cast <CShiftedFileStore*> (store);
64 Constructor. Prevents compiler warnings.
65 Actually, CShiftedFileStore instance is newer created. CFileStore or CDirectFileStore
66 instance is created and downcasted to CShiftedFileStore. It is possible to do that:
67 CShiftedFileStore doesn't have data members at all.
69 CShiftedFileStore::CShiftedFileStore(RFile& aFile) :
70 CDirectFileStore(aFile)