sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "t_inputextra.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
|
sl@0
|
22 |
EXPORT_C HBufC8* InputExtra::ReadFilesLC(CDesCArray& aFilenames, RFs& aFs)
|
sl@0
|
23 |
{
|
sl@0
|
24 |
TInt count = aFilenames.MdcaCount();
|
sl@0
|
25 |
TInt totalSize = 0;
|
sl@0
|
26 |
TInt i = 0;
|
sl@0
|
27 |
for (i = 0; i < count; i++)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
RFile file;
|
sl@0
|
30 |
User::LeaveIfError(file.Open(aFs, aFilenames.MdcaPoint(i), EFileRead));
|
sl@0
|
31 |
CleanupClosePushL(file);
|
sl@0
|
32 |
TInt size;
|
sl@0
|
33 |
file.Size(size);
|
sl@0
|
34 |
CleanupStack::PopAndDestroy(2);// fileClose
|
sl@0
|
35 |
totalSize += size;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
HBufC8* res = HBufC8::NewLC(totalSize);
|
sl@0
|
38 |
TPtr8 pRes = res->Des();
|
sl@0
|
39 |
for (i = 0; i < count; i++)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
HBufC8* cert = Input::ReadFileLC(aFilenames.MdcaPoint(i), aFs);
|
sl@0
|
42 |
pRes.Append(cert->Des());
|
sl@0
|
43 |
CleanupStack::PopAndDestroy();//cert
|
sl@0
|
44 |
}
|
sl@0
|
45 |
return res;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
EXPORT_C HBufC8* InputExtra::ReadFilesLC(CDesCArray& aFilenames, const TDesC& aPath, RFs& aFs)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
TInt count = aFilenames.MdcaCount();
|
sl@0
|
51 |
TInt totalSize = 0;
|
sl@0
|
52 |
TInt i = 0;
|
sl@0
|
53 |
for (i = 0; i < count; i++)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
HBufC* filenameBuf = HBufC::NewLC(256);
|
sl@0
|
56 |
TPtr fullFilename = filenameBuf->Des();
|
sl@0
|
57 |
fullFilename.Append(aPath);
|
sl@0
|
58 |
TPtrC filename = aFilenames.MdcaPoint(i);
|
sl@0
|
59 |
fullFilename.Append(filename);
|
sl@0
|
60 |
|
sl@0
|
61 |
RFile file;
|
sl@0
|
62 |
User::LeaveIfError(file.Open(aFs, fullFilename, EFileRead));
|
sl@0
|
63 |
CleanupClosePushL(file);
|
sl@0
|
64 |
TInt size;
|
sl@0
|
65 |
file.Size(size);
|
sl@0
|
66 |
CleanupStack::PopAndDestroy(2);//filenameBuf, fileClose
|
sl@0
|
67 |
totalSize += size;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
HBufC8* res = HBufC8::NewLC(totalSize);
|
sl@0
|
70 |
TPtr8 pRes = res->Des();
|
sl@0
|
71 |
for (i = 0; i < count; i++)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
HBufC8* cert = Input::ReadFileLC(aFilenames.MdcaPoint(i), aPath, aFs);
|
sl@0
|
74 |
pRes.Append(cert->Des());
|
sl@0
|
75 |
CleanupStack::PopAndDestroy();//cert
|
sl@0
|
76 |
}
|
sl@0
|
77 |
return res;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|