imgtools/romtools/rofsbuild/r_driveutl.cpp
changeset 647 53d1ab72f5bc
parent 626 ac03b93ca9c4
equal deleted inserted replaced
641:8dd670a9f34f 647:53d1ab72f5bc
    30 Derive log file name from the given driveobey file name(it could be absolute path)
    30 Derive log file name from the given driveobey file name(it could be absolute path)
    31         and update with .log extn.
    31         and update with .log extn.
    32 Checks the validity of driveobey file name before creating the log file name.
    32 Checks the validity of driveobey file name before creating the log file name.
    33 
    33 
    34 @param adriveobeyFileName - Drive obey file.
    34 @param adriveobeyFileName - Drive obey file.
    35 @param &apadlogfile       - Reference to log file name.
    35 @param &apadlogfile       - Log file name from command line. 
    36   
    36   
    37 @return - returns 'ErrorNone' if log file created, otherwise returns Error.
    37 @return - returns 'ErrorNone' if log file created, otherwise returns Error.
    38 */ 
    38 */ 
    39 TInt Getlogfile(char *aDriveObeyFileName,char* &aPadLogFile)
    39 string Getlogfile(char *aDriveObeyFileName,const string &CmdLogFile)
    40 	{
    40 	{
    41 
    41 	string strLogfile(CmdLogFile);
       
    42 	if(strLogfile.size() > 0 && strLogfile[strLogfile.size()-1] != '\\' && strLogfile[strLogfile.size()-1] != '/')
       
    43 		return strLogfile;
       
    44 		
    42 	if(!(*aDriveObeyFileName))
    45 	if(!(*aDriveObeyFileName))
    43 		return KErrGeneral;
    46 		return string("");
    44 
    47 
    45 	// Validate the user entered driveoby file name.
    48 	// Validate the user entered driveoby file name.
    46 	char* logFile = (char*)aDriveObeyFileName;
    49 	char* logFile = (char*)aDriveObeyFileName;
    47 
    50 
       
    51 #ifdef __LINUX__
       
    52 	logFile = strrchr(logFile,'/');
       
    53 #else
       
    54 	while(*logFile)
       
    55 		{
       
    56 		if(*logFile == '/')
       
    57 			*logFile = '\\';
       
    58 		logFile++;
       
    59 		}
       
    60 	logFile = (char*)aDriveObeyFileName;
       
    61 	logFile = strrchr(logFile,'\\');
       
    62 #endif
       
    63 	
       
    64 	if(logFile)
       
    65 		++logFile;
       
    66 	else
       
    67 		logFile = (char*)aDriveObeyFileName;
       
    68 
    48 	TInt len = strlen(logFile);
    69 	TInt len = strlen(logFile);
    49 	if(!len)
    70 	if(!len)
    50 		return KErrGeneral;
    71 		return string("");
    51 
       
    52 	// Allocates the memory for log file name.
       
    53 	aPadLogFile = new char[(len)+5]; 
       
    54 	if(!aPadLogFile)
       
    55 		return KErrNoMemory;
       
    56 
    72 
    57 	// Create the log file name.
    73 	// Create the log file name.
    58 	strcpy((char*)aPadLogFile,logFile);
    74 	strLogfile += logFile;
    59 	strcat((char*)aPadLogFile,".LOG");
    75 	strLogfile += ".LOG";
    60 				
    76 				
    61 	return  KErrNone;
    77 	return  strLogfile;
    62 	}
    78 	}
    63 
    79 
    64 /**
    80 /**
    65 Time Stamp for Log file.
    81 Time Stamp for Log file.
    66 */ 
    82 */