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