|
1 /* |
|
2 * Copyright (c) 2005-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 "sisfiledata.h" |
|
20 #include "osinterface.h" |
|
21 using namespace std; |
|
22 |
|
23 SISFileData::SISFileData() |
|
24 :iExeLabelAndCapabilities (NULL) |
|
25 { |
|
26 } |
|
27 |
|
28 int SISFileData::EciFileRead(const char* aFile , const Options& aOptions) |
|
29 { |
|
30 ifstream file; |
|
31 string line ; |
|
32 string exeCapabilitiesFile = ".\\"; |
|
33 string exeCapabilities ; |
|
34 string exeKey ; |
|
35 string exeValue; |
|
36 unsigned int exeKeyloc = 0 ; |
|
37 unsigned int exeValueloc = 0; |
|
38 exeCapabilitiesFile.append(aFile); |
|
39 file.open(aFile); |
|
40 if(!file) |
|
41 { |
|
42 throw EUnableToOpenFile; |
|
43 } |
|
44 else |
|
45 { |
|
46 ExeLabelAndCapabilitiesList* iNext = NULL; |
|
47 ExeLabelAndCapabilitiesList* node = NULL ; |
|
48 ExeLabelAndCapabilitiesList* nextNode = NULL; |
|
49 while(!file.eof()) |
|
50 { |
|
51 getline(file,line); |
|
52 if((exeKeyloc = line.find("@",0)) != string::npos) |
|
53 { |
|
54 int certCapabilities = 0; |
|
55 exeKey = line.substr(0,line.find("=",0)); |
|
56 exeValueloc = line.find("=",0); |
|
57 exeValue = line.substr(line.find("=",exeValueloc)+1); |
|
58 iExeName = exeValue.substr(0,exeValue.find("@",0)); |
|
59 if((iExeName.find(".exe") != string::npos) || (iExeName.find(".dll") !=string::npos)) |
|
60 { |
|
61 node = new ExeLabelAndCapabilitiesList; |
|
62 node->iExeCapability = 0; |
|
63 node->iExeLabel = iExeName; |
|
64 exeCapabilities = exeValue.substr(exeValue.find("@",0)+1); |
|
65 //convert string to integer in order to form an integer vector. |
|
66 std::istringstream stream(exeCapabilities); |
|
67 stream >> certCapabilities; |
|
68 node -> iExeCapability = certCapabilities ; |
|
69 node -> iNext = NULL; |
|
70 //when it is the first node in the list |
|
71 if(iExeLabelAndCapabilities == NULL) |
|
72 { |
|
73 iExeLabelAndCapabilities = node; |
|
74 } |
|
75 else |
|
76 { |
|
77 nextNode = iExeLabelAndCapabilities; |
|
78 while(nextNode -> iNext != NULL) |
|
79 { |
|
80 nextNode = nextNode->iNext; |
|
81 } |
|
82 |
|
83 nextNode -> iNext = node; |
|
84 } |
|
85 } |
|
86 } |
|
87 } |
|
88 } |
|
89 |
|
90 file.close(); |
|
91 if(!iExeLabelAndCapabilities) |
|
92 { |
|
93 cout << "SIS File doesn't contain any executables." << endl; |
|
94 return 0; |
|
95 } |
|
96 |
|
97 return 1; |
|
98 } |
|
99 |
|
100 SISFileData::~SISFileData() |
|
101 { |
|
102 for(ExeLabelAndCapabilitiesList* list = iExeLabelAndCapabilities ; list ; ) |
|
103 { |
|
104 ExeLabelAndCapabilitiesList* next = list -> iNext; |
|
105 delete list; |
|
106 list = next; |
|
107 } |
|
108 } |