imgtools/romtools/rofsbuild/r_obey.cpp
changeset 626 ac03b93ca9c4
parent 617 3a747a240983
child 647 53d1ab72f5bc
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    38 #include "r_coreimage.h"
    38 #include "r_coreimage.h"
    39 #include "patchdataprocessor.h"
    39 #include "patchdataprocessor.h"
    40 #include "fatimagegenerator.h" 
    40 #include "fatimagegenerator.h" 
    41 #include "r_driveimage.h"
    41 #include "r_driveimage.h"
    42 
    42 
       
    43 #include "uniconv.hpp"
    43 extern TInt gCodePagingOverride;
    44 extern TInt gCodePagingOverride;
    44 extern TInt gDataPagingOverride;
    45 extern TInt gDataPagingOverride;
    45 extern ECompression gCompress;
    46 extern ECompression gCompress;
    46 extern TBool gEnableStdPathWarning; // Default to not warn if destination path provided for a file is not in standard path.
    47 extern TBool gEnableStdPathWarning; // Default to not warn if destination path provided for a file is not in standard path.
    47 extern TBool gKeepGoing;
    48 extern TBool gKeepGoing;
       
    49 extern TBool gIsOBYUTF8;
    48 
    50 
    49 
    51 
    50 #define _P(word)	word, sizeof(word)-1	// match prefix, optionally followed by [HWVD]
    52 #define _P(word)	word, sizeof(word)-1	// match prefix, optionally followed by [HWVD]
    51 #define _K(word)	word, 0					// match whole word
    53 #define _K(word)	word, 0					// match whole word
    52 static char* const NullString = "" ;
    54 static char* const NullString = "" ;
    78 	{_K("dataimagename"),1, 1,EKeywordDataImageName, "Data Drive image file name"},
    80 	{_K("dataimagename"),1, 1,EKeywordDataImageName, "Data Drive image file name"},
    79 	{_K("dataimagefilesystem"),1, 1,EKeywordDataImageFileSystem, "Drive image file system format"},
    81 	{_K("dataimagefilesystem"),1, 1,EKeywordDataImageFileSystem, "Drive image file system format"},
    80 	{_K("dataimagesize"),1, 1,EKeywordDataImageSize, "Maximum size of Data Drive image"},
    82 	{_K("dataimagesize"),1, 1,EKeywordDataImageSize, "Maximum size of Data Drive image"},
    81 	{_K("volume"),1, -1,EKeywordDataImageVolume, "Volume Label of Data Drive image"},
    83 	{_K("volume"),1, -1,EKeywordDataImageVolume, "Volume Label of Data Drive image"},
    82 	{_K("sectorsize"),1, 1,EKeywordDataImageSectorSize, "Sector size(in bytes) of Data Drive image"},
    84 	{_K("sectorsize"),1, 1,EKeywordDataImageSectorSize, "Sector size(in bytes) of Data Drive image"},
       
    85 	{_K("clustersize"),1, 1,EKeywordDataImageClusterSize, "Cluster size(in bytes) of Data Drive image"},
    83 	{_K("fattable"),1, 1,EKeywordDataImageNoOfFats, "Number of FATs in the Data Drive image"},
    86 	{_K("fattable"),1, 1,EKeywordDataImageNoOfFats, "Number of FATs in the Data Drive image"},
    84 	// things we don't normally report in the help information
    87 	// things we don't normally report in the help information
    85 	{_K("trace"),		1, 1, EKeywordTrace, "(ROMBUILD activity trace flags)"},
    88 	{_K("trace"),		1, 1, EKeywordTrace, "(ROMBUILD activity trace flags)"},
    86 	{_K("filecompress"),2, -2,EKeywordFileCompress,"Non-XIP Executable to be loaded into the ROM compressed" },
    89 	{_K("filecompress"),2, -2,EKeywordFileCompress,"Non-XIP Executable to be loaded into the ROM compressed" },
    87 	{_K("fileuncompress"),2, -2,EKeywordFileUncompress,"Non-XIP Executable to be loaded into the ROM uncompressed" },
    90 	{_K("fileuncompress"),2, -2,EKeywordFileUncompress,"Non-XIP Executable to be loaded into the ROM uncompressed" },
   780 		iDriveFileFormat = iReader.DupWord(1);
   783 		iDriveFileFormat = iReader.DupWord(1);
   781 		break;
   784 		break;
   782 	case EKeywordDataImageSize:
   785 	case EKeywordDataImageSize:
   783 		{
   786 		{
   784 			const char* bigString = iReader.Word(1);
   787 			const char* bigString = iReader.Word(1);
   785 			if(*bigString == '\0')
   788 			TInt64 imagesize = 0;
       
   789 			Val(imagesize,bigString); 
       
   790 			if(imagesize <= 0)
   786 			{
   791 			{
   787 				Print(EWarning,"Not a valid Image Size. Default size is considered\n");		
   792 				Print(EWarning,"Not a valid Image Size. Default size is considered\n");		
   788 				break;
   793 			}else
   789 			}
   794 			{
   790  
   795 				iConfigurableFatAttributes.iImageSize = imagesize;
   791 			Val(iConfigurableFatAttributes.iImageSize,bigString); 
   796 			} 
   792 		}
   797 		}
   793 		break;
   798 		break;
   794 	case EKeywordDataImageVolume:
   799 	case EKeywordDataImageVolume:
   795 		{				
   800 		{				
   796 			// Get the volume label provided by using "volume" keyword.
   801 			// Get the volume label provided by using "volume" keyword.
   827 			break;
   832 			break;
   828 		}
   833 		}
   829 	case EKeywordDataImageSectorSize:
   834 	case EKeywordDataImageSectorSize:
   830 		{
   835 		{
   831 			const char* bigString = iReader.Word(1);
   836 			const char* bigString = iReader.Word(1);
   832 			TInt sectorSize = atoi(bigString);
   837 			TInt sectorSize = 0;
       
   838 			Val(sectorSize,bigString); 
   833 			if(sectorSize <= 0)	{
   839 			if(sectorSize <= 0)	{
   834 				Print(EWarning,"Invalid Sector Size value. Default value is considered.\n");
   840 				Print(EWarning,"Invalid Sector Size value. Default value is considered.\n");
   835 			}
   841 			}
   836 			else {
   842 			else {
   837 				iConfigurableFatAttributes.iDriveSectorSize = atoi(bigString);
   843 				iConfigurableFatAttributes.iDriveSectorSize = sectorSize;
       
   844 			}
       
   845 		}			
       
   846 		break;
       
   847 	case EKeywordDataImageClusterSize:
       
   848 		{
       
   849 			const char* bigString = iReader.Word(1);
       
   850 			TInt clusterSize = 0;
       
   851 			Val(clusterSize,bigString); 
       
   852 			if(clusterSize <= 0)	{
       
   853 				Print(EWarning,"Invalid Cluster Size value. Default value is considered.\n");
       
   854 			}
       
   855 			else {
       
   856 				iConfigurableFatAttributes.iDriveClusterSize = clusterSize;
   838 			}
   857 			}
   839 		}			
   858 		}			
   840 		break;
   859 		break;
   841 	case EKeywordDataImageNoOfFats:
   860 	case EKeywordDataImageNoOfFats:
   842 		{
   861 		{
   843 			const char* bigString = iReader.Word(1);
   862 			const char* bigString = iReader.Word(1);
   844 			TInt noOfFats = atoi(bigString);
   863 			TInt noOfFats = 0;
       
   864 			Val(noOfFats,bigString); 
   845 			if (noOfFats <=0)
   865 			if (noOfFats <=0)
   846 				Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n");
   866 				Print(EWarning,"Invalid No of FATs specified. Default value is considered.\n");
   847 			else
   867 			else
   848 				iConfigurableFatAttributes.iDriveNoOfFATs = atoi(bigString);			
   868 				iConfigurableFatAttributes.iDriveNoOfFATs = noOfFats;			
   849 		}			
   869 		}			
   850 		break;			
   870 		break;			
   851 	default:
   871 	default:
   852 		// unexpected keyword iReader.Word(0), keep going.
   872 		// unexpected keyword iReader.Word(0), keep going.
   853 		break;
   873 		break;
   945 	}
   965 	}
   946 
   966 
   947 	if (aKeyword!=EKeywordHide && aKeyword!=EKeywordDir) {
   967 	if (aKeyword!=EKeywordHide && aKeyword!=EKeywordDir) {
   948 		// check the PC file exists
   968 		// check the PC file exists
   949 		char* nname = NormaliseFileName(iReader.Word(1));		  
   969 		char* nname = NormaliseFileName(iReader.Word(1));		  
       
   970 		if(gIsOBYUTF8 && !UniConv::IsPureASCIITextStream(nname))
       
   971 		{
       
   972 			char* tempnname = strdup(nname);
       
   973 			unsigned int namelen = 0;
       
   974 			if(UniConv::UTF82DefaultCodePage(tempnname, strlen(tempnname), &nname, &namelen) < 0)
       
   975 			{
       
   976 				Print(EError, "Invalid filename encoding: %s\n", tempnname);
       
   977 				free(tempnname);
       
   978 				delete[] nname;
       
   979 				iMissingFiles++;
       
   980 				return EFalse;
       
   981 			}
       
   982 			free(tempnname);
       
   983 		}
   950 		ifstream test(nname);
   984 		ifstream test(nname);
   951 		if(!test.is_open()){
   985 		if(!test.is_open()){
   952 			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
   986 			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
   953 			iMissingFiles++;
   987 			iMissingFiles++;
   954 		}
   988 		}
  1299 
  1333 
  1300 	if (aKeyword!=EKeywordHideV2) {
  1334 	if (aKeyword!=EKeywordHideV2) {
  1301 
  1335 
  1302 		// check the PC file exists
  1336 		// check the PC file exists
  1303 		char* nname = NormaliseFileName(iReader.Word(1)); 
  1337 		char* nname = NormaliseFileName(iReader.Word(1)); 
       
  1338 		if(gIsOBYUTF8 && !UniConv::IsPureASCIITextStream(nname))
       
  1339 		{
       
  1340 			char* tempnname = strdup(nname);
       
  1341 			unsigned int namelen = 0;
       
  1342 			if(UniConv::UTF82DefaultCodePage(tempnname, strlen(tempnname), &nname, &namelen) < 0)
       
  1343 			{
       
  1344 				Print(EError, "Invalid filename encoding: %s\n", tempnname);
       
  1345 				free(tempnname);
       
  1346 				delete[] nname;
       
  1347 				return EFalse;
       
  1348 			}
       
  1349 			free(tempnname);
       
  1350 		}
  1304 		ifstream test(nname);
  1351 		ifstream test(nname);
  1305 		if (!test) {
  1352 		if (!test) {
  1306 			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
  1353 			Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
  1307 			iMissingFiles++;
  1354 			iMissingFiles++;
  1308 		}
  1355 		}
  1636 		iAutoSize = ETrue;
  1683 		iAutoSize = ETrue;
  1637 		Val(iAutoPageSize,iReader.Word(1));
  1684 		Val(iAutoPageSize,iReader.Word(1));
  1638 		break;
  1685 		break;
  1639 	default:
  1686 	default:
  1640 		// unexpected keyword iReader.Word(0)
  1687 		// unexpected keyword iReader.Word(0)
       
  1688 		Print(EWarning, "Unexpected keyword '%s' on line %d.\n",iReader.Word(0),iReader.CurrentLine());
  1641 		break;
  1689 		break;
  1642 	}
  1690 	}
  1643 
  1691 
  1644 	return success;
  1692 	return success;
  1645 }
  1693 }