61 Creates package parser object for each of the package file |
58 Creates package parser object for each of the package file |
62 |
59 |
63 @internalComponent |
60 @internalComponent |
64 @released |
61 @released |
65 */ |
62 */ |
66 void Sis2Iby::ProcessSisFile() |
63 void Sis2Iby::ProcessSisFile() { |
67 { |
|
68 TUint32 retStatus = STAT_SUCCESS; |
64 TUint32 retStatus = STAT_SUCCESS; |
69 String sisFile = SisFileName(); |
65 string sisFile = SisFileName(); |
70 |
66 |
71 if(IsVerboseMode()) |
67 if(IsVerboseMode()) { |
72 { |
68 cout << "Processing " << sisFile.c_str() << endl; |
73 std::cout << "Processing " << (char*)sisFile.data() << std::endl; |
69 } |
74 } |
70 |
75 |
71 if(IsFileExist(sisFile)) { |
76 if(IsFileExist(sisFile)) |
|
77 { |
|
78 retStatus = InvokeExtractTool(sisFile); |
72 retStatus = InvokeExtractTool(sisFile); |
79 |
73 |
80 switch(retStatus) |
74 switch(retStatus) { |
81 { |
75 case STAT_SUCCESS: |
82 case STAT_SUCCESS: |
76 UpdatePkgFileMap(iExtractPath, sisFile); |
83 { |
|
84 UpdatePkgFileMap(iExtractPath, sisFile); |
|
85 } |
|
86 break; |
77 break; |
87 case STAT_FAILURE: |
78 case STAT_FAILURE: |
88 { |
79 throw SisUtilsException(sisFile.c_str(), "Failed to extract SIS file"); |
89 throw SisUtilsException((char*)sisFile.data(), "Failed to extract SIS file"); |
80 break ; |
90 } |
|
91 } |
81 } |
92 } |
82 } |
93 else |
83 else |
94 throw SisUtilsException((char*)sisFile.data(), "File not found"); |
84 throw SisUtilsException(sisFile.c_str(), "File not found"); |
95 } |
85 } |
96 |
86 |
97 /** |
87 /** |
98 GenerateOutput: Generates IBY for each of the package file |
88 GenerateOutput: Generates IBY for each of the package file |
99 |
89 |
100 @internalComponent |
90 @internalComponent |
101 @released |
91 @released |
102 */ |
92 */ |
103 void Sis2Iby::GenerateOutput() |
93 void Sis2Iby::GenerateOutput() { |
104 { |
|
105 PKGFILE_MAP::iterator begin = iPkgFileMap.begin(); |
94 PKGFILE_MAP::iterator begin = iPkgFileMap.begin(); |
106 PKGFILE_MAP::iterator end = iPkgFileMap.end(); |
95 PKGFILE_MAP::iterator end = iPkgFileMap.end(); |
107 while(begin != end) |
96 while(begin != end) { |
108 { |
|
109 GenerateIby((*begin).first, (*begin).second); |
97 GenerateIby((*begin).first, (*begin).second); |
110 ++begin; |
98 ++begin; |
111 } |
99 } |
112 } |
100 } |
113 |
101 |
118 @released |
106 @released |
119 |
107 |
120 @param aPkgFile - package file name |
108 @param aPkgFile - package file name |
121 @param aParser - corresponding package file reader object |
109 @param aParser - corresponding package file reader object |
122 */ |
110 */ |
123 void Sis2Iby::GenerateIby(String aPkgFile, PPKGPARSER aParser) |
111 void Sis2Iby::GenerateIby(string aPkgFile, PPKGPARSER aParser) { |
124 { |
112 string ibyFile = iOutputPath; |
125 String ibyFile = iOutputPath; |
|
126 |
113 |
127 AppendFileName(ibyFile, aPkgFile); |
114 AppendFileName(ibyFile, aPkgFile); |
128 ibyFile.append(".iby"); |
115 ibyFile.append(".iby"); |
129 |
116 |
130 if( !MakeDirectory(iOutputPath) ) |
117 if( !MakeDirectory(iOutputPath) ) |
131 throw SisUtilsException((char*)iOutputPath.data(), "Failed to create path"); |
118 throw SisUtilsException(iOutputPath.c_str(), "Failed to create path"); |
132 |
119 |
133 if(IsVerboseMode()) |
120 if(IsVerboseMode()) { |
134 { |
121 cout << "Generating IBY file " << ibyFile.c_str() << endl; |
135 std::cout << "Generating IBY file " << (char*)ibyFile.data() << std::endl; |
122 } |
136 } |
123 |
137 |
124 ibyHandle.open(ibyFile.c_str(),ios_base::out); |
138 ibyHandle.open((char*)ibyFile.data(),(std::ios::out)); |
125 |
139 |
126 if(!ibyHandle.good()) { |
140 if(!ibyHandle.good()) |
127 throw SisUtilsException(ibyFile.c_str() , "Failed to create IBY file"); |
141 { |
|
142 throw SisUtilsException((char*)ibyFile.data(), "Failed to create IBY file"); |
|
143 } |
128 } |
144 |
129 |
145 // Generating Header |
130 // Generating Header |
146 MakeFullPath(aPkgFile); |
131 MakeFullPath(aPkgFile); |
147 ibyHandle << "\n// Generated IBY file for the package file: "; |
132 ibyHandle << "\n// Generated IBY file for the package file: "; |
168 @internalComponent |
153 @internalComponent |
169 @released |
154 @released |
170 |
155 |
171 @param sisFile - SIS file name |
156 @param sisFile - SIS file name |
172 */ |
157 */ |
173 TUint32 Sis2Iby::InvokeExtractTool(String sisFile) |
158 TUint32 Sis2Iby::InvokeExtractTool(const string& aSisFile) { |
174 { |
159 string cmdLine; |
175 String cmdLine; |
|
176 |
160 |
177 cmdLine.append(SISEXTRACT_TOOL_NAME SISEXTRACT_TOOL_DEFOPT); |
161 cmdLine.append(SISEXTRACT_TOOL_NAME SISEXTRACT_TOOL_DEFOPT); |
178 |
162 |
179 AppendFileName(iExtractPath, sisFile); |
163 AppendFileName(iExtractPath, aSisFile); |
180 |
164 |
181 cmdLine.append(SISEXTRACT_TOOL_EXTOPT); |
165 cmdLine.append(SISEXTRACT_TOOL_EXTOPT); |
182 cmdLine.append("\"" + iExtractPath + "\" "); |
166 cmdLine.append("\"" + iExtractPath + "\" "); |
183 cmdLine.append(sisFile); |
167 cmdLine.append(aSisFile); |
184 |
168 |
185 if(IsVerboseMode()) |
169 if(IsVerboseMode()) { |
186 { |
170 cout << "Executing " << cmdLine.c_str() << endl; |
187 std::cout << "Executing " << (char*)cmdLine.data() << std::endl; |
171 } |
188 } |
172 |
189 |
173 return RunCommand(cmdLine.c_str()); |
190 return RunCommand(cmdLine); |
|
191 } |
174 } |
192 |
175 |
193 /** |
176 /** |
194 UpdatePkgFileMap: Update the package file map by getting the embedded sis file list from the parser object |
177 UpdatePkgFileMap: Update the package file map by getting the embedded sis file list from the parser object |
195 |
178 |
197 @released |
180 @released |
198 |
181 |
199 @param aPath - Extract path |
182 @param aPath - Extract path |
200 @param aFile - SIS file name |
183 @param aFile - SIS file name |
201 */ |
184 */ |
202 void Sis2Iby::UpdatePkgFileMap(String aPath, String aFile) |
185 void Sis2Iby::UpdatePkgFileMap(const string& aPath, const string& aFile) { |
203 { |
186 string pkgFileName; |
204 String pkgFileName; |
187 list<string> sisList; |
205 std::list<String> sisList; |
|
206 |
188 |
207 // main pkg file |
189 // main pkg file |
208 pkgFileName = aPath; |
190 pkgFileName = aPath; |
209 AppendFileName(pkgFileName, aFile); |
191 AppendFileName(pkgFileName, aFile); |
210 pkgFileName.append(".pkg"); |
192 pkgFileName.append(".pkg"); |
211 |
193 |
212 // create an instance for the pkg file parser |
194 // create an instance for the pkg file parser |
213 // get the embedded sis file list |
195 // get the embedded sis file list |
214 // add each as pkg file into the list |
196 // add each as pkg file into the list |
215 pkgParser = 0; |
197 pkgParser = 0; |
216 if( IsFileExist(pkgFileName) ) |
198 if( IsFileExist(pkgFileName) ) { |
217 { |
|
218 pkgParser = new PkgParser(pkgFileName); |
199 pkgParser = new PkgParser(pkgFileName); |
219 |
200 |
220 if(pkgParser) |
201 if(pkgParser) { |
221 { |
|
222 pkgParser->ParsePkgFile(); |
202 pkgParser->ParsePkgFile(); |
223 |
203 |
224 iPkgFileMap[pkgFileName] = pkgParser; |
204 iPkgFileMap[pkgFileName] = pkgParser; |
225 |
205 |
226 pkgParser->GetEmbeddedSisList(sisList); |
206 pkgParser->GetEmbeddedSisList(sisList); |
227 SISFILE_LIST::iterator begin = sisList.begin(); |
207 SISFILE_LIST::iterator begin = sisList.begin(); |
228 SISFILE_LIST::iterator end = sisList.end(); |
208 SISFILE_LIST::iterator end = sisList.end(); |
229 |
209 |
230 while(begin != end) |
210 while(begin != end) { |
231 { |
211 string currPath = aPath; |
232 String currPath = aPath; |
|
233 |
212 |
234 currPath.append(PATHSEPARATOR); |
213 currPath.append(PATHSEPARATOR); |
235 GetFileName((*begin), currPath); |
214 GetFileName((*begin), currPath); |
236 UpdatePkgFileMap(currPath, (*begin)); |
215 UpdatePkgFileMap(currPath, (*begin)); |
237 |
216 |
238 ++begin; |
217 ++begin; |
239 } |
218 } |
240 } |
219 } |
241 else |
220 else |
242 throw SisUtilsException((char*)pkgFileName.data(), "Could not create parser object"); |
221 throw SisUtilsException(pkgFileName.c_str(), "Could not create parser object"); |
243 } |
222 } |
244 else |
223 else |
245 throw SisUtilsException((char*)pkgFileName.data(), "File not found"); |
224 throw SisUtilsException(pkgFileName.c_str(), "File not found"); |
246 } |
225 } |
247 |
226 |
248 /** |
227 /** |
249 WriteLanguages: Writes language section in the IBY file |
228 WriteLanguages: Writes language section in the IBY file |
250 |
229 |
251 @internalComponent |
230 @internalComponent |
252 @released |
231 @released |
253 |
232 |
254 @param aParser - Package file parser object |
233 @param aParser - Package file parser object |
255 */ |
234 */ |
256 void Sis2Iby::WriteLanguages(PPKGPARSER aParser) |
235 void Sis2Iby::WriteLanguages(PPKGPARSER aParser) { |
257 { |
|
258 LANGUAGE_LIST lanMap; |
236 LANGUAGE_LIST lanMap; |
259 PLANG_LIST langCode; |
237 PLANG_LIST iLangCode; |
260 |
238 |
261 aParser->GetLanguageList(lanMap); |
239 aParser->GetLanguageList(lanMap); |
262 ibyHandle << "\n// Languages: "; |
240 ibyHandle << "\n// Languages: "; |
263 |
241 |
264 LANGUAGE_LIST::iterator begin = lanMap.begin(); |
242 LANGUAGE_LIST::iterator begin = lanMap.begin(); |
265 LANGUAGE_LIST::iterator end = lanMap.end(); |
243 LANGUAGE_LIST::iterator end = lanMap.end(); |
266 |
244 |
267 while(begin != end) |
245 while(begin != end) { |
268 { |
246 iLangCode = (*begin); |
269 langCode = (*begin); |
247 |
270 |
248 ibyHandle << " " << iLangCode->iLangName; |
271 ibyHandle << " " << langCode->langName; |
249 ibyHandle << "(" << iLangCode->iLangCode; |
272 ibyHandle << "(" << langCode->langCode; |
250 |
273 |
251 if(iLangCode->iDialectCode) { |
274 if(langCode->dialectCode) |
252 ibyHandle << "-" << iLangCode->iDialectCode; |
275 { |
|
276 ibyHandle << "-" << langCode->dialectCode; |
|
277 } |
253 } |
278 ibyHandle << ")"; |
254 ibyHandle << ")"; |
279 |
255 |
280 ++begin; |
256 ++begin; |
281 } |
257 } |
287 @internalComponent |
263 @internalComponent |
288 @released |
264 @released |
289 |
265 |
290 @param aParser - Package file parser object |
266 @param aParser - Package file parser object |
291 */ |
267 */ |
292 void Sis2Iby::WritePackageHeader(PPKGPARSER aParser) |
268 void Sis2Iby::WritePackageHeader(PPKGPARSER aParser) { |
293 { |
|
294 PKG_HEADER pkgHeader; |
269 PKG_HEADER pkgHeader; |
295 std::list<String> pkgList; |
270 list<string> pkgList; |
296 std::ostringstream str; |
271 ostringstream str; |
297 |
272 |
298 aParser->GetHeader(pkgHeader); |
273 aParser->GetHeader(pkgHeader); |
299 |
274 |
300 ibyHandle << "\n// Header: "; |
275 ibyHandle << "\n// Header: "; |
301 |
276 |
302 pkgList = pkgHeader.pkgNameList; |
277 pkgList = pkgHeader.iPkgNames; |
303 while(pkgList.size()) |
278 while(pkgList.size()) |
304 { |
279 { |
305 ibyHandle << "\"" << pkgList.front() << "\" "; |
280 ibyHandle << "\"" << pkgList.front() << "\" "; |
306 pkgList.pop_front(); |
281 pkgList.pop_front(); |
307 } |
282 } |
308 |
283 |
309 str << "(0x" << std::setbase(16) << pkgHeader.pkgUid << ")"; |
284 str << "(0x" << setbase(16) << pkgHeader.iPkgUID << ")"; |
310 |
285 |
311 ibyHandle << str.str(); |
286 ibyHandle << str.str(); |
312 } |
287 } |
313 |
288 |
314 /** |
289 /** |
317 @internalComponent |
292 @internalComponent |
318 @released |
293 @released |
319 |
294 |
320 @param aParser - Package file parser object |
295 @param aParser - Package file parser object |
321 */ |
296 */ |
322 void Sis2Iby::WriteInstallOptions(PPKGPARSER aParser) |
297 void Sis2Iby::WriteInstallOptions(PPKGPARSER aParser) { |
323 { |
298 list<string> optList; |
324 std::list<String> optList; |
299 string ibyName; |
325 String ibyName; |
|
326 |
300 |
327 aParser->GetInstallOptions(optList); |
301 aParser->GetInstallOptions(optList); |
328 SISFILE_LIST::iterator begin = optList.begin(); |
302 SISFILE_LIST::iterator begin = optList.begin(); |
329 SISFILE_LIST::iterator end = optList.end(); |
303 SISFILE_LIST::iterator end = optList.end(); |
330 |
304 |
331 if(begin != end) |
305 if(begin != end) { |
332 { |
|
333 ibyHandle << "\n// Install Options: "; |
306 ibyHandle << "\n// Install Options: "; |
334 } |
307 } |
335 |
308 |
336 while(begin != end) |
309 while(begin != end) { |
337 { |
|
338 ibyHandle << " \"" << (*begin) << "\""; |
310 ibyHandle << " \"" << (*begin) << "\""; |
339 ++begin; |
311 ++begin; |
340 } |
312 } |
341 } |
313 } |
342 |
314 |
363 @internalComponent |
333 @internalComponent |
364 @released |
334 @released |
365 |
335 |
366 @param aParser - Package file parser object |
336 @param aParser - Package file parser object |
367 */ |
337 */ |
368 void Sis2Iby::WritePackageBody(PPKGPARSER aParser) |
338 void Sis2Iby::WritePackageBody(PPKGPARSER aParser) { |
369 { |
|
370 CMDBLOCK_LIST cmdList; |
339 CMDBLOCK_LIST cmdList; |
371 PCMD_BLOCK cmd; |
340 PCMD_BLOCK cmd; |
372 int pad = 0; |
341 TInt pad = 0; |
373 |
342 |
374 ibyHandle << "\n\n"; |
343 ibyHandle << "\n\n"; |
375 aParser->GetCommandList(cmdList); |
344 aParser->GetCommandList(cmdList); |
376 |
345 |
377 CMDBLOCK_LIST::iterator begin = cmdList.begin(); |
346 CMDBLOCK_LIST::iterator begin = cmdList.begin(); |
378 CMDBLOCK_LIST::iterator end = cmdList.end(); |
347 CMDBLOCK_LIST::iterator end = cmdList.end(); |
379 |
348 |
380 while(begin != end) |
349 while(begin != end) { |
381 { |
|
382 cmd = (*begin); |
350 cmd = (*begin); |
383 |
351 |
384 switch(cmd->cmdType) |
352 switch(cmd->iCmdType) |
385 { |
353 { |
386 case IF: |
354 case IF: |
387 { |
355 InsertTabs(pad); |
388 InsertTabs(pad); |
356 ibyHandle << "#if " << cmd->iCmdExpr; |
389 ibyHandle << "#if " << cmd->cmdExpression; |
357 pad++; |
390 pad++; |
358 |
391 } |
359 break; |
392 break; |
360 case ELSEIF: |
393 case ELSEIF: |
361 InsertTabs(pad-1); |
394 { |
362 ibyHandle << "#elif " << cmd->iCmdExpr; |
395 InsertTabs(pad-1); |
363 break; |
396 ibyHandle << "#elif " << cmd->cmdExpression; |
364 case ELSE: |
397 } |
365 InsertTabs(pad-1); |
398 break; |
366 ibyHandle << "#else"; |
399 case ELSE: |
367 break; |
400 { |
368 case ENDIF: |
401 InsertTabs(pad-1); |
369 --pad; |
402 ibyHandle << "#else"; |
370 InsertTabs(pad); |
403 } |
371 ibyHandle << "#endif"; |
404 break; |
372 break; |
405 case ENDIF: |
373 case INSTALLFILE: |
406 { |
374 WriteInstallFileList(cmd->iInstallFileList, aParser, pad); |
407 --pad; |
375 break; |
408 InsertTabs(pad); |
376 case PACKAGE: |
409 ibyHandle << "#endif"; |
377 InsertTabs(pad); |
410 } |
378 ibyHandle << "#include " << "\"" << cmd->iCmdExpr << "\""; |
411 break; |
|
412 case INSTALLFILE: |
|
413 { |
|
414 WriteInstallFileList(cmd->iInstallFileList, aParser, pad); |
|
415 } |
|
416 break; |
|
417 case PACKAGE: |
|
418 { |
|
419 InsertTabs(pad); |
|
420 ibyHandle << "#include " << "\"" << cmd->cmdExpression << "\""; |
|
421 } |
|
422 break; |
379 break; |
423 } |
380 } |
424 |
381 |
425 ++begin; |
382 ++begin; |
426 } |
383 } |
434 |
391 |
435 @param aSrcFile - Name of the source file |
392 @param aSrcFile - Name of the source file |
436 @param aDestFile - Name of the destination file |
393 @param aDestFile - Name of the destination file |
437 @param aPkgName - Name of the package file |
394 @param aPkgName - Name of the package file |
438 */ |
395 */ |
439 void Sis2Iby::WriteFileInclusion(String aSrcFile, String aDestFile, String aPkgName, int pad) |
396 void Sis2Iby::WriteFileInclusion(string aSrcFile, string aDestFile, string aPkgName, TInt aPadding) { |
440 { |
|
441 NormaliseSourceFile(aSrcFile, aPkgName); |
397 NormaliseSourceFile(aSrcFile, aPkgName); |
442 |
398 |
443 InsertTabs(pad); |
399 InsertTabs(aPadding); |
444 if(IsValidE32Image(aSrcFile)) |
400 if(IsValidE32Image(aSrcFile)){ |
445 { |
|
446 ibyHandle << "file = "; |
401 ibyHandle << "file = "; |
447 } |
402 } |
448 else |
403 else { |
449 { |
|
450 ibyHandle << "data = "; |
404 ibyHandle << "data = "; |
451 } |
405 } |
452 |
406 |
453 ibyHandle << aSrcFile << " "; |
407 ibyHandle << aSrcFile << " "; |
454 NormaliseDestFile(aDestFile); |
408 NormaliseDestFile(aDestFile); |
463 |
417 |
464 @param aFileList - Installable file list structure |
418 @param aFileList - Installable file list structure |
465 @param aParser - Package file parser object |
419 @param aParser - Package file parser object |
466 @param pad - Number of spaces for indentation purpose |
420 @param pad - Number of spaces for indentation purpose |
467 */ |
421 */ |
468 void Sis2Iby::WriteInstallFileList(PINSTALLFILE_LIST aFileList, PPKGPARSER aParser, int pad) |
422 void Sis2Iby::WriteInstallFileList(PINSTALLFILE_LIST aFileList, PPKGPARSER aParser, TInt aPadding) { |
469 { |
423 WriteFileInclusion(aFileList->iSourceFiles.front(), aFileList->iDestFile, aParser->GetPkgFileName(), aPadding); |
470 WriteFileInclusion(aFileList->srcFiles.front(), aFileList->destFile, aParser->GetPkgFileName(), pad); |
|
471 } |
424 } |
472 |
425 |
473 /** |
426 /** |
474 AppendFileName: Appends file name to the given path |
427 AppendFileName: Appends file name to the given path |
475 |
428 |
477 @released |
430 @released |
478 |
431 |
479 @param aPath - Source path |
432 @param aPath - Source path |
480 @param aFile - File name |
433 @param aFile - File name |
481 */ |
434 */ |
482 void Sis2Iby::AppendFileName(String& aPath, String aFile) |
435 void Sis2Iby::AppendFileName(string& aPath, string aFile) { |
483 { |
|
484 TUint pos = 0; |
436 TUint pos = 0; |
485 |
437 |
486 TrimQuotes(aPath); |
438 TrimQuotes(aPath); |
487 TrimQuotes(aFile); |
439 TrimQuotes(aFile); |
488 |
440 |
489 pos = aPath.rfind(PATHSEPARATOR); |
441 pos = aPath.rfind(PATHSEPARATOR); |
490 if(pos == String::npos) |
442 if(pos == string::npos) { |
491 { |
|
492 aPath.append(PATHSEPARATOR); |
443 aPath.append(PATHSEPARATOR); |
493 } |
444 } |
494 |
445 |
495 if(pos < (aPath.length()-1)) |
446 if(pos < (aPath.length() - 1)) { |
496 { |
|
497 aPath.append(PATHSEPARATOR); |
447 aPath.append(PATHSEPARATOR); |
498 } |
448 } |
499 |
449 |
500 GetFileName(aFile, aPath); |
450 GetFileName(aFile, aPath); |
501 return; |
451 return; |
508 @released |
458 @released |
509 |
459 |
510 @param aName - Input file name |
460 @param aName - Input file name |
511 @param aFile - Output parameter to hold the return value |
461 @param aFile - Output parameter to hold the return value |
512 */ |
462 */ |
513 void Sis2Iby::GetFileName(String aName, String& aFile) |
463 void Sis2Iby::GetFileName(const string& aName, string& aFile) { |
514 { |
|
515 TUint spos = 0, epos = 0; |
464 TUint spos = 0, epos = 0; |
516 |
465 |
517 spos = aName.rfind(PATHSEPARATOR); |
466 spos = aName.rfind(PATHSEPARATOR); |
518 if(spos != String::npos) |
467 if(spos != string::npos) { |
519 { |
|
520 spos += 1; |
468 spos += 1; |
521 } |
469 } |
522 else |
470 else { |
523 { |
|
524 spos = 0; |
471 spos = 0; |
525 } |
472 } |
526 |
473 |
527 epos = aName.rfind("."); |
474 epos = aName.rfind("."); |
528 if(epos == String::npos) |
475 if(epos == string::npos) { |
529 { |
|
530 epos = aName.size(); |
476 epos = aName.size(); |
531 } |
477 } |
532 |
478 |
533 aFile.append(aName.substr(spos, (epos-spos))); |
479 aFile.append(aName.substr(spos, (epos-spos))); |
534 } |
480 } |
563 @released |
506 @released |
564 |
507 |
565 @param aFile - Input file name |
508 @param aFile - Input file name |
566 @param aPkgFile - Package file path |
509 @param aPkgFile - Package file path |
567 */ |
510 */ |
568 void Sis2Iby::NormaliseSourceFile(String& aFile, String aPkgFile) |
511 void Sis2Iby::NormaliseSourceFile(string& aFile, const string& aPkgFile) { |
569 { |
512 string result; |
570 String result; |
|
571 TUint pos = 0; |
513 TUint pos = 0; |
572 |
514 |
573 pos = aPkgFile.rfind(PATHSEPARATOR); |
515 pos = aPkgFile.rfind(PATHSEPARATOR); |
574 if(pos != String::npos) |
516 if(pos != string::npos) { |
575 { |
|
576 result = aPkgFile.substr(0,pos); |
517 result = aPkgFile.substr(0,pos); |
577 } |
518 } |
578 else |
519 else { |
579 { |
|
580 result = "."; |
520 result = "."; |
581 } |
521 } |
582 |
522 |
583 result.append(PATHSEPARATOR); |
523 result.append(PATHSEPARATOR); |
584 result.append(aFile); |
524 result.append(aFile); |
594 @internalComponent |
534 @internalComponent |
595 @released |
535 @released |
596 |
536 |
597 @param aFile - Input file name |
537 @param aFile - Input file name |
598 */ |
538 */ |
599 void Sis2Iby::NormaliseDestFile(String& aFile) |
539 void Sis2Iby::NormaliseDestFile(string& aFile) { |
600 { |
540 TUint pos = 0; |
601 TUint pos = 0; |
|
602 |
|
603 /** Comment by KunXu to fix DEF122540 on 18 Jun 2008 |
|
604 pos = aFile.find("$:"); |
|
605 if(pos != String::npos) |
|
606 { |
|
607 aFile.replace(pos, 2, ""); |
|
608 } |
|
609 |
|
610 pos = aFile.find("!:"); |
|
611 if(pos != String::npos) |
|
612 { |
|
613 aFile.replace(pos, 2, ""); |
|
614 } |
|
615 **/ |
|
616 |
|
617 /** Add by KunXu to fix DEF122540 on 18 Jun 2008 **/ |
|
618 /** Ignore any drive indication in the filename to generate an iby file **/ |
|
619 /** Begin **/ |
|
620 pos = aFile.find(":"); |
541 pos = aFile.find(":"); |
621 if (1 == pos) |
542 if (1 == pos) { |
622 { |
|
623 char chFirst = aFile[0]; |
543 char chFirst = aFile[0]; |
624 if ('$' == chFirst || '!' == chFirst || (chFirst >='a' && chFirst <='z') || (chFirst >='A' && chFirst <='Z')) |
544 if ('$' == chFirst || '!' == chFirst || (chFirst >='a' && chFirst <='z') || (chFirst >='A' && chFirst <='Z')) { |
625 { |
|
626 aFile.replace(0, 2, ""); |
545 aFile.replace(0, 2, ""); |
627 } |
546 } |
628 } |
547 } |
629 /** End **/ |
548 |
630 |
549 |
631 aFile = "\"" + aFile + "\""; |
550 aFile = "\"" + aFile + "\""; |
632 } |
551 } |
633 |
552 |
634 /** |
553 /** |
637 @internalComponent |
556 @internalComponent |
638 @released |
557 @released |
639 |
558 |
640 @param aFile - Input file name |
559 @param aFile - Input file name |
641 */ |
560 */ |
642 TBool Sis2Iby::IsValidE32Image(String aFile) |
561 TBool Sis2Iby::IsValidE32Image(string aFile) { |
643 { |
562 ifstream file; |
644 std::ifstream aIfs; |
563 char sig[5]; |
645 TInt8 aSig[5]; |
|
646 TUint32 e32SigOffset = 0x10, fileSize = 0; |
564 TUint32 e32SigOffset = 0x10, fileSize = 0; |
647 TBool validE32 = EFalse; |
565 TBool validE32 = EFalse; |
648 |
566 |
649 TrimQuotes(aFile); |
567 TrimQuotes(aFile); |
650 |
568 |
651 aIfs.open(aFile.c_str(), std::ios::in | std::ios::binary); |
569 file.open(aFile.c_str(), ios_base::in | ios_base::binary); |
652 |
570 |
653 if( !aIfs.is_open() ) |
571 if( !file.is_open() ) { |
654 { |
572 throw SisUtilsException(aFile.c_str(), "Cannot open file"); |
655 throw SisUtilsException((char*)aFile.data(), "Cannot open file"); |
573 } |
656 } |
574 |
657 |
575 file.seekg(0,ios_base::end); |
658 aIfs.seekg(0,std::ios::end); |
576 fileSize = file.tellg(); |
659 fileSize = aIfs.tellg(); |
577 if(fileSize > 20) { |
660 if(fileSize > 20) |
578 file.seekg(e32SigOffset,ios_base::beg); |
661 { |
579 file.read(sig, 4); |
662 aIfs.seekg(e32SigOffset,std::ios::beg); |
580 sig[4] = '\0'; |
663 aIfs.read((char*)aSig, 4); |
581 |
664 aSig[4] = '\0'; |
582 if(!strcmp(sig, "EPOC")) { |
665 |
|
666 if(!strcmp((char*)aSig, "EPOC")) |
|
667 { |
|
668 validE32 = ETrue; |
583 validE32 = ETrue; |
669 } |
584 } |
670 } |
585 } |
671 |
586 |
672 aIfs.close(); |
587 file.close(); |
673 |
|
674 return validE32; |
588 return validE32; |
675 } |
589 } |