os/graphics/fbs/fontandbitmapserver/sfbs/ShiftedFileStore.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "ShiftedFileStore.h"
sl@0
    17
sl@0
    18
/**
sl@0
    19
@internalComponent
sl@0
    20
CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset) method.
sl@0
    21
CFileStore::OpenL(RFs& aFs,const TDesC& aName,TUint aFileMode,const TFileStoreFactoryFunction aFactory[])
sl@0
    22
method was used as an origin for the method's source code.
sl@0
    23
*/
sl@0
    24
CShiftedFileStore* CShiftedFileStore::OpenLC(RFs& aFs, const TDesC& aName, TUint aFileMode, TUint aFileOffset)
sl@0
    25
	{
sl@0
    26
	RFile file;
sl@0
    27
	User::LeaveIfError(file.Open(aFs, aName, aFileMode));
sl@0
    28
	CShiftedFileStore* store = FromL(file, aFileOffset);
sl@0
    29
	CleanupStack::PushL(store);
sl@0
    30
	return store;
sl@0
    31
	}
sl@0
    32
sl@0
    33
/**
sl@0
    34
@internalComponent
sl@0
    35
CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset) method.
sl@0
    36
CFileStore::FromL(RFile& aFile,TFileStoreFactoryFunction aFunction) method was used as an origin
sl@0
    37
for the method's source code. The only difference is that RFileBuf::Attach is called with possibly
sl@0
    38
non-zero offset. The original implementation always calls RFileBuf::Attach with zero offset.
sl@0
    39
*/
sl@0
    40
CShiftedFileStore* CShiftedFileStore::FromL(RFile& aFile, TUint aFileOffset)
sl@0
    41
	{
sl@0
    42
	if (static_cast<TInt>(aFileOffset) < 0)
sl@0
    43
		User::Leave(KErrArgument);
sl@0
    44
	RFileBuf buf;
sl@0
    45
	buf.Attach(aFile, static_cast <TInt> (aFileOffset));
sl@0
    46
	buf.PushL();
sl@0
    47
	RReadStream stream(&buf);
sl@0
    48
	TCheckedUid chk;
sl@0
    49
	stream >> chk;
sl@0
    50
	CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType());
sl@0
    51
	if(store == NULL)
sl@0
    52
		User::Leave(KErrNotSupported);
sl@0
    53
	//CleanupStack::Pop(2) is called, because:
sl@0
    54
	//1) buf.PushL() - actually MStreamBuf::PushL() is called and it pushes buf 
sl@0
    55
	//                 into CleanupStack.
sl@0
    56
	//1) CFileStore* store = (*KDirectFileStoreFactoryFunction)(buf, chk.UidType()) -
sl@0
    57
	//                 FileStoreFactory::DirectLC() is called.
sl@0
    58
	CleanupStack::Pop(2);
sl@0
    59
	return static_cast <CShiftedFileStore*> (store);
sl@0
    60
	}
sl@0
    61
sl@0
    62
/**
sl@0
    63
@internalComponent
sl@0
    64
Constructor. Prevents compiler warnings.
sl@0
    65
Actually, CShiftedFileStore instance is newer created. CFileStore or CDirectFileStore
sl@0
    66
instance is created and downcasted to CShiftedFileStore. It is possible to do that:
sl@0
    67
CShiftedFileStore doesn't have data members at all.
sl@0
    68
*/
sl@0
    69
CShiftedFileStore::CShiftedFileStore(RFile& aFile) :
sl@0
    70
	CDirectFileStore(aFile)
sl@0
    71
	{
sl@0
    72
	}
sl@0
    73