imgtools/romtools/rofsbuild/rofsbuild.cpp
changeset 647 53d1ab72f5bc
parent 631 9435b9008a58
child 654 7c11c3d8d025
child 655 3f65fd25dfd4
equal deleted inserted replaced
641:8dd670a9f34f 647:53d1ab72f5bc
    44 #define stricmp strcasecmp
    44 #define stricmp strcasecmp
    45 #define _alloca alloca
    45 #define _alloca alloca
    46 #endif
    46 #endif
    47 
    47 
    48 static const TInt RofsbuildMajorVersion=2;
    48 static const TInt RofsbuildMajorVersion=2;
    49 static const TInt RofsbuildMinorVersion=13;
    49 static const TInt RofsbuildMinorVersion=14;
    50 static const TInt RofsbuildPatchVersion=2;
    50 static const TInt RofsbuildPatchVersion=1;
    51 static TBool SizeSummary=EFalse;
    51 static TBool SizeSummary=EFalse;
    52 static TPrintType SizeWhere=EAlways;
    52 static TPrintType SizeWhere=EAlways;
    53 
    53 
    54 static TInt gHeaderType=1;			// EPOC header
    54 static TInt gHeaderType=1;			// EPOC header
    55 static TInt MAXIMUM_THREADS = 128;
    55 static TInt MAXIMUM_THREADS = 128;
    75 string gDriveFilename = "";		// input drive oby filename.
    75 string gDriveFilename = "";		// input drive oby filename.
    76 string filename;				// to store oby filename passed to Rofsbuild.
    76 string filename;				// to store oby filename passed to Rofsbuild.
    77 TBool reallyHelp = EFalse;	
    77 TBool reallyHelp = EFalse;	
    78 TBool gSmrImage = EFalse;
    78 TBool gSmrImage = EFalse;
    79 string gSmrFileName = "";
    79 string gSmrFileName = "";
    80 static string rofslogfile = "ROFSBUILD.LOG";
    80 static string cmdlogfile = "";
    81 
    81 
    82 //Cache global variables
    82 //Cache global variables
    83 bool gCache = false;
    83 bool gCache = false;
    84 bool gCleanCache = false;
    84 bool gCleanCache = false;
    85 bool gNoCache = false;
    85 bool gNoCache = false;
   321 			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
   321 			else if( stricmp(argv[i], "-LOGLEVEL0") == 0)
   322 				gLogLevel = DEFAULT_LOG_LEVEL;
   322 				gLogLevel = DEFAULT_LOG_LEVEL;
   323 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   323 			else if (stricmp(argv[i], "-LOWMEM") == 0)
   324 				gLowMem = ETrue;
   324 				gLowMem = ETrue;
   325 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
   325 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
   326 				rofslogfile = argv[i] + 9;
   326 				cmdlogfile = argv[i] + 9;
   327 			}
   327 			}
   328 			else {
   328 			else {
   329 #ifdef WIN32
   329 #ifdef WIN32
   330 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   330 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
   331 #else
   331 #else
   384 @param aobeyFileName - Drive obey file.
   384 @param aobeyFileName - Drive obey file.
   385 @param alogfile      - log file name required for file system module.
   385 @param alogfile      - log file name required for file system module.
   386 
   386 
   387 @return - returns the status, after processing the drive obey file.
   387 @return - returns the status, after processing the drive obey file.
   388 */ 
   388 */ 
   389 TInt ProcessDataDriveMain(char* aobeyFileName,char* alogfile) {
   389 TInt ProcessDataDriveMain(char* aobeyFileName, const char* alogfile) {
   390 
   390 
   391 	ObeyFileReader *reader = new ObeyFileReader(aobeyFileName);
   391 	ObeyFileReader *reader = new ObeyFileReader(aobeyFileName);
   392 
   392 
   393 	if(!reader)
   393 	if(!reader)
   394 		return KErrNoMemory;
   394 		return KErrNoMemory;
   430 	delete mainObeyFile;
   430 	delete mainObeyFile;
   431 	delete reader;
   431 	delete reader;
   432 	return retstatus;
   432 	return retstatus;
   433 }
   433 }
   434 
   434 
   435 TInt ProcessSmrImageMain(char* aObeyFileName, char* /* alogfile */) {
   435 TInt ProcessSmrImageMain(char* aObeyFileName, const char* /* alogfile */) {
   436 	ObeyFileReader *reader = new ObeyFileReader(aObeyFileName);
   436 	ObeyFileReader *reader = new ObeyFileReader(aObeyFileName);
   437 	if(!reader)
   437 	if(!reader)
   438 		return KErrNoMemory;
   438 		return KErrNoMemory;
   439 	if(!reader->Open())
   439 	if(!reader->Open())
   440 		return KErrGeneral;
   440 		return KErrGeneral;
   534 		do {
   534 		do {
   535 			while(((temp = *ptr++) != ',') && (temp != 0));
   535 			while(((temp = *ptr++) != ',') && (temp != 0));
   536 			*(--ptr)++ = 0; 
   536 			*(--ptr)++ = 0; 
   537 
   537 
   538 			if(*driveobeyFileName) {
   538 			if(*driveobeyFileName) {
   539 				char* logfile = 0;
   539 				string logfile = Getlogfile(driveobeyFileName, cmdlogfile);
   540 				if(Getlogfile(driveobeyFileName,logfile) == KErrNone) {
   540 				if(logfile.size() > 0) {
   541 					H.SetLogFile(logfile);
   541 					H.SetLogFile(logfile.c_str());
   542 					GetLocalTime();
   542 					GetLocalTime();
   543 					r = ProcessDataDriveMain(driveobeyFileName,logfile);   
   543 					r = ProcessDataDriveMain(driveobeyFileName,logfile.c_str());   
   544 					H.CloseLogFile();
   544 					H.CloseLogFile();
   545 					delete[] logfile;
       
   546 					if(r == KErrNoMemory)
   545 					if(r == KErrNoMemory)
   547 						return KErrNoMemory;
   546 						return KErrNoMemory;
   548 				}
   547 				}
   549 				else {
   548 				else {
   550 					Print(EError,"Invalid obey file name : %s\n", driveobeyFileName);   
   549 					Print(EError,"Invalid obey file name : %s\n", driveobeyFileName);   
   562 		do {
   561 		do {
   563 			while(((temp = *ptr++) != ',') && (temp != 0));
   562 			while(((temp = *ptr++) != ',') && (temp != 0));
   564 			*(--ptr)++ = 0;
   563 			*(--ptr)++ = 0;
   565 
   564 
   566 			if(*smrImageObeyFileName){	
   565 			if(*smrImageObeyFileName){	
   567 				char * logfile = 0;
   566 				string logfile = Getlogfile(smrImageObeyFileName, cmdlogfile);
   568 				if(Getlogfile(smrImageObeyFileName,logfile) == KErrNone){
   567 				if(logfile.size() > 0) {
   569 					H.SetLogFile(logfile);
   568 					H.SetLogFile(logfile.c_str());
   570 					GetLocalTime();
   569 					GetLocalTime();
   571 					r = ProcessSmrImageMain(smrImageObeyFileName, logfile);
   570 					r = ProcessSmrImageMain(smrImageObeyFileName, logfile.c_str());
   572 					H.CloseLogFile();
   571 					H.CloseLogFile();
   573 					delete[] logfile;
       
   574 					if(r == KErrNoMemory)
   572 					if(r == KErrNoMemory)
   575 						return KErrNoMemory;
   573 						return KErrNoMemory;
   576 				}
   574 				}
   577 				else {
   575 				else {
   578 					Print(EError,"Invalid obey file name: %s", smrImageObeyFileName);
   576 					Print(EError,"Invalid obey file name: %s", smrImageObeyFileName);
   582 		} while(temp != 0);
   580 		} while(temp != 0);
   583 		gSmrImage = EFalse;
   581 		gSmrImage = EFalse;
   584 	}
   582 	}
   585 	// Process Rofs Obey files.
   583 	// Process Rofs Obey files.
   586 	if(obeyFileName) {
   584 	if(obeyFileName) {
   587 		if (rofslogfile[rofslogfile.size()-1] == '\\' || rofslogfile[rofslogfile.size()-1] == '/')
   585 		if (cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/')
   588 			rofslogfile += "ROFSBUILD.LOG";
   586 			cmdlogfile += "ROFSBUILD.LOG";
   589 	 	H.SetLogFile(rofslogfile.c_str());
   587 	 	H.SetLogFile(cmdlogfile.c_str());
   590 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   588 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
   591 		if (!reader->Open())
   589 		if (!reader->Open())
   592 			return KErrGeneral;
   590 			return KErrGeneral;
   593 
   591 
   594 		E32Rofs* RofsImage = 0;		// for image from obey file
   592 		E32Rofs* RofsImage = 0;		// for image from obey file