secureswitools/swisistools/source/sisxlibrary/sisfiledescription.cpp
changeset 26 04d4a7bbc3e0
parent 0 ba25891c3a9e
equal deleted inserted replaced
25:98b66e4fb0be 26:04d4a7bbc3e0
    94 		{L"<"},
    94 		{L"<"},
    95 		{L">"},
    95 		{L">"},
    96 		{NULL}
    96 		{NULL}
    97 	};
    97 	};
    98 
    98 
       
    99 int FileOrData = 0;
    99 void CSISFileDescription::InsertMembers ()
   100 void CSISFileDescription::InsertMembers ()
   100 	{
   101 	{
   101 	InsertMember (iTarget);
   102 	InsertMember (iTarget);
   102 	InsertMember (iMimeType);
   103 	InsertMember (iMimeType);
   103 	InsertMember (iCapabilities);
   104 	InsertMember (iCapabilities);
   362 #endif 
   363 #endif 
   363 	iCapabilities.ExtractCapabilities(aFileName);
   364 	iCapabilities.ExtractCapabilities(aFileName);
   364 	
   365 	
   365 	}
   366 	}
   366 
   367 
   367 void CSISFileDescription::AddPackageEntry(std::wostream& aStream, bool aVerbose) const
   368 void CSISFileDescription::AddPackageEntry(std::wostream& aStream, bool aVerbose, bool aCompatible) const
   368 	{
   369 	{
       
   370 	std::wstring filePath = iTarget.GetString();
   369 	aStream <<L";";
   371 	aStream <<L";";
   370 	iTarget.AddPackageEntry(aStream, aVerbose);
   372 	iTarget.AddPackageEntry(aStream, aVerbose, aCompatible);
   371 	aStream << std::endl << L"; File length " << iLength << L" (" << iUncompressedLength << L")" << std::endl;
   373 	aStream << std::endl << L"; File length " << iLength << L" (" << iUncompressedLength << L")" << std::endl;
   372 	iCapabilities.AddPackageEntry(aStream, aVerbose);
   374 	iCapabilities.AddPackageEntry(aStream, aVerbose, aCompatible);
   373 	iHash.AddPackageEntry(aStream, aVerbose);
   375 	iHash.AddPackageEntry(aStream, aVerbose, aCompatible);
   374 	
   376 	
   375 	const wchar_t* fileName = GetFileName(); 
   377 	if(aCompatible)
   376 	
   378 		{
   377 	aStream <<std::endl <<L"\"" << fileName << L"\"";
   379 		const wchar_t* fileName = GetFileName(); 
   378 	delete[] const_cast<wchar_t*>(fileName);
   380 		aStream << L"\"" << fileName << L"\"";
       
   381 		delete[] const_cast<wchar_t*>(fileName);
       
   382 		}
       
   383 	else
       
   384 		{
       
   385 		int index = filePath.find_first_of(L":");
       
   386 		if(index!=-1)
       
   387 				filePath = filePath.substr(index+2,filePath.length()-index-2);
       
   388 
       
   389 		aStream << L"\"" << filePath << L"\"";
       
   390 		}
       
   391 
   379 	aStream << L"-";
   392 	aStream << L"-";
   380 	aStream << L"\"";
   393 	aStream << L"\"";
   381 	iTarget.AddPackageEntry(aStream, aVerbose);
   394 	iTarget.AddPackageEntry(aStream, aVerbose, aCompatible);
   382 	aStream << L"\"";
   395 	aStream << L"\"";
   383 
   396 
   384 	TUint32 operation = (TUint32) iOperation;
   397 	TUint32 operation = (TUint32) iOperation;
   385 	TUint32 options = (TUint32) iOperationOptions;
   398 	TUint32 options = (TUint32) iOperationOptions;
   386 
   399 
   401 		operation &= ~EOpRun;
   414 		operation &= ~EOpRun;
   402 		if (options & EInstFileRunOptionByMimeType)
   415 		if (options & EInstFileRunOptionByMimeType)
   403 			{
   416 			{
   404 			options &= ~EInstFileRunOptionByMimeType;
   417 			options &= ~EInstFileRunOptionByMimeType;
   405 			aStream << L", " << (aVerbose?L"FILEMIME, ":L"FM,\" ");
   418 			aStream << L", " << (aVerbose?L"FILEMIME, ":L"FM,\" ");
   406 			iMimeType.AddPackageEntry(aStream, aVerbose);
   419 			iMimeType.AddPackageEntry(aStream, aVerbose, aCompatible);
   407 			aStream<<L"\"";
   420 			aStream<<L"\"";
   408 			}
   421 			}
   409 		else
   422 		else
   410 			{
   423 			{
   411 			aStream << L", " << (aVerbose?L"FILERUN":L"FR");
   424 			aStream << L", " << (aVerbose?L"FILERUN":L"FR");
   491 		{
   504 		{
   492 		aStream << L"; (warning: unparsed option(s) on preceding line" << std::endl;
   505 		aStream << L"; (warning: unparsed option(s) on preceding line" << std::endl;
   493 		}
   506 		}
   494 	}
   507 	}
   495 
   508 
       
   509 void CSISFileDescription::AddIbyEntry(std::wostream& aStream, bool aVerbose, bool aCompatible) const
       
   510 	{
       
   511 	std::wstring fileExt = iTarget.GetString();
       
   512 	std::wstring filePath = fileExt;
       
   513 	if(fileExt.length()>0)
       
   514 		{
       
   515 		int index = fileExt.find_last_of(L".");
       
   516 		if(index!=-1)
       
   517 			fileExt = fileExt.substr(index+1,fileExt.length()-index-1);
       
   518 		}
       
   519 
       
   520 	if(fileExt.compare(L"exe")==0 || fileExt.compare(L"EXE")==0 || fileExt.compare(L"dll")==0 || fileExt.compare(L"DLL")==0)
       
   521 		{
       
   522 		if(FileOrData==2)
       
   523 			aStream << std::endl;
       
   524 			
       
   525 		FileOrData = 1;
       
   526 		}
       
   527 	else
       
   528 		{
       
   529 		if(FileOrData==1)
       
   530 			aStream << std::endl;
       
   531 			
       
   532 		FileOrData = 2;
       
   533 		}
       
   534 
       
   535 	if(fileExt.length()==0)
       
   536 		aStream << L"; Unknown file name" << std::endl;
       
   537 
       
   538 	aStream << L"; File length " << iLength << L" (" << iUncompressedLength << L")";
       
   539 	
       
   540 	aStream << std::endl;
       
   541 
       
   542 	if(fileExt.length()==0)
       
   543 		aStream << L"; ";
       
   544 
       
   545 	if(FileOrData==1)
       
   546 		aStream << L"file=";
       
   547 	else
       
   548 		aStream << L"data=";
       
   549 
       
   550 	if(aCompatible)
       
   551 		{
       
   552 		const wchar_t* fileName = GetFileName(); 
       
   553 		aStream << L"\"" << fileName << L"\"";
       
   554 		delete[] const_cast<wchar_t*>(fileName);
       
   555 		}
       
   556 	else
       
   557 		{
       
   558 		int index = filePath.find_first_of(L":");
       
   559 		if(index!=-1)
       
   560 				filePath = filePath.substr(index+2,filePath.length()-index-2);
       
   561 
       
   562 		aStream << L"\"" << filePath << L"\"";
       
   563 		}
       
   564 	aStream << L"          ";
       
   565 	aStream << L"\"";
       
   566 	iTarget.AddIbyEntry(aStream, aVerbose, aCompatible);
       
   567 	aStream << L"\"";
       
   568 
       
   569 	aStream << std::endl;
       
   570 	}
   496 const wchar_t* CSISFileDescription::GetFileName() const
   571 const wchar_t* CSISFileDescription::GetFileName() const
   497 	{
   572 	{
   498 	// Using actual iFileIndex rather than iFileNum because source file might be
   573 	// Using actual iFileIndex rather than iFileNum because source file might be
   499 	// the same for several targets and hence has an index different from simple
   574 	// the same for several targets and hence has an index different from simple
   500 	// sequentual ordinal value
   575 	// sequentual ordinal value