Update Scripts Copy Files Simplified
Simplified Script to copy files.
//********************************************************************* // // RT4 SYSTEM_UPGRADE.CMD Simplified Script // //********************************************************************* /*** UPGRADE FLAGS ***/ #define FORCE_SOFTWARE_UPGRADE 0 // delete everything on /F/Application /C/Application and /C/Data_base #define ENABLE_CRC_CHECK 1 // saves time if = 0 /*** GLOBAL DEFINES ****/ // Upgrade types typedef enum { NORMAL = 0, BOOTROM, RECOVERY }t_UPGType; typedef int (*FUNCPTR)(char *sourcedrive, int reboot_at_end); // Script Types typedef int STATUS; typedef void DIR; typedef int BOOL; typedef int size_t; typedef void FILE; typedef void *MODULE_ID; #define TRUE (1) #define FALSE (0) #define OK (0) #define ERROR (-1) #define NULL (void*) 0 #define O_RDONLY (0) #define O_RDWR (2) // Constants #define MAX_DRIVE_NAME_LENGTH 10 #define MAX_FILENAME_LENGTH 50 #define MAX_PATH_LENGTH 100 #define MAX_VERSION_LENGTH 95 #define MAX_CRC_LENGTH 20 #define MAX_QUESTION_LENGTH 50 #define MAX_DATE_CLOCK_LENGTH 100 #define MODULE_NO_VERSION "0000" #define TEMP_UPGRADE_DIR "/UPG" #define RECOVERY_FILE "/recovery.lst" #define BACKUP_DIR "/C/BACKUP" #define BACKUP_BR_DIR "/C/BACKUP_BR" #define FSEARCH_TABLE_FILE "/bd0/UPG/Table/table_upgrade_excl.dat" #define LOAD_NO_SYMBOLS 2 #define LOAD_LOCAL_SYMBOLS 4 #define LOAD_GLOBAL_SYMBOLS 8 #define LOAD_ALL_SYMBOLS 12 // Drive letters #define DRIVE_CDROM "/D" #define DRIVE_HDD "/C" #define DRIVE_TFFS "/F" #define DRIVE_USB "/bd0" #define DRIVE_NAV "/H" #define DRIVE_USER "/I" /*** SOFTWARE UPGRADE DEFINES ***/ typedef struct { int m_iIsNew; char m_pVersion[MAX_VERSION_LENGTH]; char m_pFileName[MAX_PATH_LENGTH]; char m_pTargetPath[MAX_PATH_LENGTH]; int m_iSize; } t_SoftUpgData; #define MAX_APPLI_FILES 1000 /*** EXTERN FUNCTION DECLARATIONS ***/ // File operations VxWorks int open (const char * name, int flags, int mode); STATUS close (int fd); char* fgets(char * buf, size_t n, FILE * fp); int fputs(char * s, FILE * fp); FILE* fopen(char * file, char * mode ); int fclose(FILE * fp); int feof(FILE * fp); DIR* opendir (char * dirName); STATUS closedir (DIR *dir); STATUS xdelete (const char * source); STATUS mv(char * src, char * dest); STATUS xcopy ( char *src, char *dst ); // File operations builtins STATUS UPGCopy (char* p_source, char* p_dest, int p_cut); STATUS UPGDelete (char* p_file); STATUS UPGMKDir (char* p_dir); STATUS UPGMKDelete (char* p_dir); int SearchAndTargetFileExclu ( char *Filename, char *Tablename, char *Param[], int NbParams, char *RootDir, char *TargetDir ); STATUS GetSearchResult(int index , char *SearchResult, char *targetPath ); int UPGSearchFile(char *Filename, char *RootDir, char *Param, char *TableDir ); STATUS UPGGetSearchResult(int index , char *SearchResult ); STATUS GetFileSize(char *file, int *size); STATUS GetFileVersion (char *l_pBynaryFileName, char *l_pVersion); STATUS ReadFileCRC(char *l_pBynaryFileName, char *l_pCRC); STATUS CheckCRCFile(char *l_file); // String operations STATUS strcpy (char* target, char* source); STATUS strcat (char* target, char* source); int strcmp (char* str1, char* str2); int strncmp (char* str1, char* str2, int n); STATUS strlen (char* str); char* strstr(char* str, char* substr); // MMI UPG Panel management STATUS ShowBargraph(void); STATUS ClearScreen(void); STATUS StepBargraph(char *text, int index); STATUS ShowCDVerification(void); STATUS ShowCDProblem(void); STATUS ShowGSMCallInProgress(void); STATUS ShowQuestionScreen(char *text, int *answer); // Logging STATUS SetUpgradeLogging( int TRUEFALSE ); STATUS EnableHistoryHandler ( int TRUEFALSE ); STATUS AddUPGHistoryHeader(char *p_CDNum, char *p_TargetDrive, char *p_Action); STATUS UPGLogMsg(char* str,int p1,int p2,int p3,int p4,int p5,int p6); // Others VxWorks unsigned long tickGet (void); STATUS taskDelay (int ticks); int logMsg (char* str,int p1,int p2,int p3,int p4,int p5,int p6); MODULE_ID loadModule(int fd, int loadFlag); // Other Builtins STATUS SetCDVersion(char *cdVersion); STATUS GetCDVersion(char *cdVersion); STATUS GetBootromVersion( char *p_version ); STATUS EmergencyReboot( void ); void SetRebootAfterScript( int truefalse); void* UPGFindSymbol( char *symbol ); STATUS ExecuteFlasherOut( void *funcPtr, char *sourceDrive, int rebootAtEnd ); STATUS GetSourceDrive( char *srcDrive ); STATUS GetUpgradeType( char *upgType ); STATUS SetPower( int stayOn); STATUS CheckCRCDrive ( char *p_pSourceDrive ); int IsUpgCheatCodeActivated ( void ); STATUS GetCurrentDateClock(char *l_pDateClock); STATUS SetUPGInProgressInCDD ( int TRUEFALSE ); int GsmCallInProgress(void); STATUS UpdateFSImage(void); STATUS ComputeCRCFile(char *l_pFileName, char *l_pCRC); STATUS StopHDDActivity (void); STATUS SetRedLedOn(void); STATUS SetMasterFlashingOn(void); STATUS Execute( void *funcPtr ); int IsPartitionUnderRepair(void); STATUS SetPartitionRepairState( int true_False); STATUS EnableSetPowerOffHandler(void); STATUS InstallHDDTestFiles(void); STATUS BootRomFormatTffs(void); int atoi(char * s); /*** INTERN FUNCTION DECLARATION ***/ STATUS PrepareSoftUpg(t_SoftUpgData *p_pSoftUpgList, char *p_pSourceDrive, char *p_pRootDir, char *p_pMask, char *p_pTargetDrive, char *p_pSearchParams[], int p_pNbSearchParams, int p_iCheckVersion, unsigned long *p_totalSize ); STATUS InstallSoftList( t_SoftUpgData *p_pList, unsigned long p_totalSize, t_UPGType p_upgType, unsigned long *p_completedSize, BOOL p_use_temp_names_for_recovery ); int FileExists(char *p_pPath); void VerueExtUpgCdrom ( char *p_pPath ); STATUS EndUpgrade(char *p_SourceDrive); /****************************** MAIN ******************************/ int main(int argc, char **argv) { // Local variables for general purpose STATUS l_script_status = OK; char l_pSourceDrive[MAX_DRIVE_NAME_LENGTH]; char l_pTargetDrive[MAX_DRIVE_NAME_LENGTH]; char l_pSourceVersion[MAX_VERSION_LENGTH]; char l_pTargetVersion[MAX_VERSION_LENGTH]; int l_i=0; t_UPGType l_tUpgType; char l_pPath[MAX_PATH_LENGTH]; char l_pSourcePath[MAX_PATH_LENGTH]; char l_pTargetPath[MAX_PATH_LENGTH]; char l_pCDVersion[MAX_VERSION_LENGTH]; char l_pOldCDVersion[MAX_VERSION_LENGTH]; char l_pQuestionText[MAX_QUESTION_LENGTH]; int l_iIsUpgRequired = FALSE; char l_pDateClock[MAX_DATE_CLOCK_LENGTH]; int l_IsPartitionUnderRepair = FALSE; // Software upgrade variables unsigned long l_lTotalSize = 0; unsigned long l_lCompletedSize = 0; char l_pString[MAX_PATH_LENGTH]; DIR* l_pDir; t_SoftUpgData l_pSoftList[MAX_APPLI_FILES]; t_SoftUpgData l_pTffsList[MAX_APPLI_FILES]; t_SoftUpgData l_pSpyCopyList[MAX_APPLI_FILES]; int l_iNbSearchParams = 0; char* l_pSearchParams[2]; char l_pSearchParam1[MAX_PATH_LENGTH]; char l_pSearchParam2[MAX_PATH_LENGTH]; BOOL l_enable_recovery = FALSE; //Added stuff char l_computeCrc[MAX_PATH_LENGTH]; char l_rdCrc[MAX_PATH_LENGTH]; char l_CRC_target_path[MAX_PATH_LENGTH]; // External upgrade variables int l_iFromAppli = FALSE; char l_pVersion[MAX_VERSION_LENGTH]; int l_FpInLoader = FALSE; char l_pFPVersion[MAX_VERSION_LENGTH]; // Bootrom upgrade variable int l_iBootromUpgRequired = FALSE; int l_iFd = 0; MODULE_ID l_pModuleId = NULL; FUNCPTR l_pFuncPtr =NULL; l_pSearchParams[0] = l_pSearchParam1; l_pSearchParams[1] = l_pSearchParam2; /*** SCRIPT INITIALIZATION ***/ SetUpgradeLogging( TRUE ); EnableHistoryHandler( TRUE ); //In case of power failure, switch off mainboard EnableSetPowerOffHandler(); //Force Mainboard power supply in case of FP Reboot SetPower( TRUE ); UPGLogMsg("Script initialization +, Time = %ld\n",tickGet(),0,0,0,0,0); if ( ERROR == GetCurrentDateClock(l_pDateClock) ) { UPGLogMsg("Unable to determine current date\n",0,0,0,0,0,0); } else { UPGLogMsg("Current date is %s\n",l_pDateClock,0,0,0,0,0); } UPGLogMsg("*********************************************\n", 0,0,0,0,0,0); //To enable any of these commands, remove the single line comments // or multi-line comments /* ..... */ //Deletes File on path //UPGDelete ("/F/USER_DATA/User_profile/User_com.dat.inf"); //Copies file FROM path, TO path, Boolean "Move" (TRUE = move, FALSE = copy) //UPGCopy ("/bd0/PUT/User_com.dat","/I/USER_DATA/User_profile/User_com.dat",FALSE); /* // Drive letters #define DRIVE_CDROM "/D" #define DRIVE_HDD "/C" #define DRIVE_TFFS "/F" #define DRIVE_USB "/bd0" #define DRIVE_NAV "/H" #define DRIVE_USER "/I" */ // Duplicates the content of USER Partition on I folder on USB //If the destination files already exist they are overwritten. UPGMKDir ( "/bd0/I"); l_tUpgType = NORMAL; strcpy ( l_pSearchParams[0], "N3" ); strcpy ( l_pSearchParams[1], "Normal" ); l_iNbSearchParams = 2; if ( ERROR == PrepareSoftUpg(l_pSpyCopyList,DRIVE_USER,"","*.*","/bd0/I",l_pSearchParams,2,FALSE,&l_lTotalSize) ) { UPGLogMsg ( "PrepareSoftUpg ERROR\n",0,0,0,0,0,0 ); } else if ( ERROR == InstallSoftList ( l_pSpyCopyList, l_lTotalSize, l_tUpgType, &l_lCompletedSize, FALSE ) ) { UPGLogMsg ( "Install l_pSoftList error\n",0,0,0,0,0,0 ); } // Copy USER_COM.DAT from USER Partition to USB UPGMKDir ( "/bd0/GET"); UPGCopy ("/I/USER_DATA/User_profile/User_com.dat","/bd0/GET/User_com.dat",FALSE); // Copy USER_COM.DAT from USB to USER Partition //UPGCopy ("/bd0/PUT/User_com.dat","/I/USER_DATA/User_profile/User_com.dat",FALSE); //UPGCopy ("/bd0/PUT/User_com.dat.inf","/I/USER_DATA/User_profile/User_com.dat.inf",FALSE); //Creates "done" Directory on USB root //If it already exists doesn't do anything (no errors) UPGMKDir ( "/bd0/done"); UPGLogMsg("*************************************************************\n", 0,0,0,0,0,0); if ( NORMAL == l_tUpgType ) { SetRebootAfterScript( TRUE ); } if ( OK == l_script_status ) { if ( NORMAL == l_tUpgType ) { strcpy ( l_pQuestionText, "Script Ended Correctly!" ); ShowQuestionScreen(l_pQuestionText, &l_iIsUpgRequired); UPGLogMsg ( "Script ended\n", 0,0,0,0,0,0 ); SetRebootAfterScript(FALSE); EndUpgrade( l_pSourceDrive ); return ( l_script_status ); } } } /********************** INTERN FUNCTION DEFINITION **********************/ STATUS EndUpgrade(char *p_SourceDrive) { char l_pPath[MAX_PATH_LENGTH]; // Clean temp directory strcpy ( l_pPath, DRIVE_HDD ); strcat ( l_pPath, TEMP_UPGRADE_DIR ); xdelete ( l_pPath ); UPGMKDelete( l_pPath ); // Stop logging EnableHistoryHandler( FALSE ); SetUpgradeLogging( FALSE ); // Disable set power SetPower ( FALSE ); return ( OK ); } STATUS PrepareSoftUpg ( t_SoftUpgData *p_pList, char *p_pSourceDrive, char *p_pRootDir, char *p_pMask, char *p_pTargetDrive, char *p_pSearchParams[], int p_iNbSearchParams, int p_pCheckVersion, unsigned long *p_pTotalSize ) { STATUS l_status = OK; int l_bIsNew = FALSE; int l_i; int l_iCountInserted; BOOL l_bUpgRequired; char l_pSearchRootDir[MAX_PATH_LENGTH]; char l_pTargetDir[MAX_PATH_LENGTH]; char l_pSearchResult[MAX_PATH_LENGTH]; int l_iNumSearchResult = 0; char l_pTablePath[MAX_PATH_LENGTH]; char l_pTargetPath[MAX_PATH_LENGTH]; char l_pSourceVersion[MAX_VERSION_LENGTH]; char l_pTargetVersion[MAX_VERSION_LENGTH]; char l_pSourceCRC[MAX_CRC_LENGTH]; char l_pTargetCRC[MAX_CRC_LENGTH]; int l_iSize; char l_pInfPath[MAX_PATH_LENGTH]; static long l_total_size_examined = 0; int l_percentage = 0; UPGLogMsg("PrepareUPGSoft +, Time = %ld\n",tickGet(),0,0,0,0,0); // Set counter of files inserted in list for(l_iCountInserted=0; (p_pList[l_iCountInserted].m_iSize) && (l_iCountInserted<MAX_APPLI_FILES); l_iCountInserted++); if ( MAX_APPLI_FILES == l_iCountInserted ) { UPGLogMsg ( "FATAL ERROR: Too many files in list\n",0,0,0,0,0,0 ); return(ERROR); } // Search all soft files on source drive // strcpy ( l_pTablePath, p_pSourceDrive ); strcat ( l_pTablePath, FSEARCH_TABLE_FILE ); strcpy ( l_pSearchRootDir, p_pSourceDrive ); strcat ( l_pSearchRootDir, p_pRootDir ); strcpy ( l_pTargetDir, p_pTargetDrive ); strcat ( l_pTargetDir, p_pRootDir ); l_iNumSearchResult = SearchAndTargetFileExclu ( p_pMask, l_pTablePath, p_pSearchParams, p_iNbSearchParams, l_pSearchRootDir, l_pTargetDir ); if ( 0 == l_iNumSearchResult ) { UPGLogMsg ( "WARNING : %s 0 occurences found on\n",p_pMask,l_pSearchRootDir,0,0,0,0 ); } // Process search result for (l_i=0; (l_i<l_iNumSearchResult) && (OK==l_status); l_i++) { l_bUpgRequired = FALSE; l_bIsNew = FALSE; l_pSourceVersion[0]='\0'; if ( ERROR == GetSearchResult ( l_i , l_pSearchResult, l_pTargetPath ) ) { UPGLogMsg ( "UPGGetSearchResult error\n",0,0,0,0,0,0 ); l_status = ERROR; } else { if ( strlen(l_pSearchResult) && (NULL == strstr(l_pSearchResult, ".inf" )) ) { if ( FALSE == p_pCheckVersion ) { if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (NO VERSION CHECK)\n",l_pTargetPath,0,0,0,0,0 ); } else if ( ERROR == GetFileVersion( l_pSearchResult, l_pSourceVersion ) ) { UPGLogMsg ( "WARNING: GetFileVersion on <%s>\n",l_pSearchResult,0,0,0,0,0 ); if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (NO VERSION CHECK)\n",l_pTargetPath,0,0,0,0,0 ); } else if ( ERROR == GetFileVersion( l_pTargetPath, l_pTargetVersion ) ) { if ( FALSE == FileExists(l_pTargetPath) ) { l_bIsNew = TRUE; } l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else if ( strcmp(l_pSourceVersion,l_pTargetVersion) || (FORCE_SOFTWARE_UPGRADE == 1) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> need update from %s to %s\n",l_pTargetPath,l_pTargetVersion,l_pSourceVersion,0,0,0 ); } // Also check CRCs in case of same version number else { if ( ERROR == ReadFileCRC( l_pSearchResult, l_pSourceCRC ) ) { UPGLogMsg ( "ERROR: Cannot read CRC of %s\n",l_pSearchResult,0,0,0,0,0 ); l_status = ERROR; } else if ( ERROR == ReadFileCRC( l_pTargetPath, l_pTargetCRC ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "WARNING: Cannot read CRC of %s\n",l_pTargetPath,0,0,0,0,0 ); UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else if ( strcmp( l_pSourceCRC, l_pTargetCRC ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "<%s> CRC differs from source (%s to %s)\n",l_pTargetPath,l_pTargetCRC,l_pSourceCRC,0,0,0 ); UPGLogMsg ( "File will be updated (%s)\n",l_pTargetVersion,0,0,0,0,0 ); } // Also check file on HDD else if ( ERROR == CheckCRCFile( l_pTargetPath ) ) { l_bUpgRequired = TRUE; UPGLogMsg ( "CheckCRCFile failed on <%s>\n",l_pTargetPath,0,0,0,0,0 ); UPGLogMsg ( "<%s> will be installed (%s)\n",l_pTargetPath,l_pSourceVersion,0,0,0,0 ); } else { UPGLogMsg ( "<%s> is up to date (%s)\n",l_pTargetPath,l_pTargetVersion,0,0,0,0 ); } } } } // Get file size if ( OK == l_status ) { if ( ERROR == GetFileSize(l_pSearchResult, &l_iSize) ) { UPGLogMsg ( "GetFileSize ERROR on %s\n",l_pSearchResult,0,0,0,0,0 ); l_status = ERROR; } else { l_total_size_examined += l_iSize; l_percentage = (int)((((long double)(l_total_size_examined)) / ((long double)525000000))*100); StepBargraph( "CRC", l_percentage ); taskDelay(100); } } // If the file needs an update if ( TRUE == l_bUpgRequired ) { // Check file coherency if ( ( OK == l_status ) && ( ENABLE_CRC_CHECK == 1 ) ) { strcpy ( l_pInfPath, l_pSearchResult ); strcat ( l_pInfPath, ".inf" ); if ( TRUE == FileExists ( l_pInfPath ) ) { if ( ERROR == CheckCRCFile( l_pSearchResult ) ) { UPGLogMsg ( "FATAL ERROR : CheckCRCFile ERROR on %s\n", l_pSearchResult,0,0,0,0,0 ); ShowCDProblem(); //taskDelay(1500); l_status = ERROR; } } } // Insert into soft upg list if ( OK == l_status ) { p_pList[l_iCountInserted].m_iIsNew = l_bIsNew; p_pList[l_iCountInserted].m_iSize = l_iSize; *p_pTotalSize += l_iSize; strcpy (p_pList[l_iCountInserted].m_pFileName, l_pSearchResult); strcpy (p_pList[l_iCountInserted].m_pTargetPath, l_pTargetPath); strcpy (p_pList[l_iCountInserted].m_pVersion, l_pSourceVersion); l_iCountInserted++; // If there is an associated inf file, insert it in list if ( TRUE == FileExists(l_pInfPath) ) { if ( TRUE == l_bIsNew ) { UPGLogMsg ( "<%s.inf> will be installed\n",l_pTargetPath,0,0,0,0,0 ); } else { UPGLogMsg ( "<%s.inf> will be updated\n",l_pTargetPath,0,0,0,0,0 ); } p_pList[l_iCountInserted].m_iIsNew = l_bIsNew; if ( ERROR == GetFileSize(l_pInfPath, &l_iSize) ) { UPGLogMsg ( "GetFileSize ERROR on %s\n",l_pInfPath,0,0,0,0,0 ); l_status = ERROR; } else { p_pList[l_iCountInserted].m_iSize = l_iSize; *p_pTotalSize += l_iSize; strcpy (p_pList[l_iCountInserted].m_pFileName, l_pSearchResult); strcat (p_pList[l_iCountInserted].m_pFileName, ".inf"); strcpy (p_pList[l_iCountInserted].m_pTargetPath, l_pTargetPath); strcat (p_pList[l_iCountInserted].m_pTargetPath, ".inf"); strcpy (p_pList[l_iCountInserted].m_pVersion, l_pSourceVersion); l_iCountInserted++; } } } } } UPGLogMsg("PrepareUPGSoft -, Time = %ld\n",tickGet(),0,0,0,0,0); return ( l_status ) ; } STATUS InstallSoftList( t_SoftUpgData *p_pList, unsigned long p_lTotalSize, t_UPGType p_tUpgType, unsigned long *p_pCompletedSize, BOOL p_use_temp_names_for_recovery ) { STATUS l_status = OK; int l_i; unsigned long l_lCompletedSize = *p_pCompletedSize; unsigned long l_lPercentage = 0; unsigned int l_percentage = 0; char l_target_path[MAX_PATH_LENGTH]; char l_actualCRC[MAX_PATH_LENGTH]; char l_readCRC[MAX_PATH_LENGTH]; int l_CopyIntegrity = ERROR; int l_retry = 0; //Go through file list for ( l_i=0; 0 != p_pList[l_i].m_iSize;l_i++ ) { //Try and retry to install l_CopyIntegrity = ERROR; for ( l_retry=0; (l_retry < 3) && (ERROR == l_CopyIntegrity); l_retry++) { //Construct the target path in case of recovery strcpy( l_target_path, p_pList[l_i].m_pTargetPath ); if ( ( TRUE == p_use_temp_names_for_recovery ) && ( NORMAL == p_tUpgType ) ) { strcat( l_target_path, ".UPG" ); } //File copy if ( ERROR == UPGCopy( p_pList[l_i].m_pFileName, l_target_path, FALSE) ) { UPGLogMsg ( "Error copying %s\n",(char*)p_pList[l_i].m_pFileName,0,0,0,0,0 ); l_status = ERROR; break; } else { //Check that source and target CRC matches if( ( NULL == strstr( p_pList[l_i].m_pFileName, ".inf" ) ) && ( NULL == strstr( p_pList[l_i].m_pFileName, ".ini" ) ) && ( NULL == strstr( p_pList[l_i].m_pFileName, ".INI" ) ) ) { //Compute target file CRC if ( ERROR == ComputeCRCFile(l_target_path,l_actualCRC) ) { UPGLogMsg( "WARNING: Cannot compute CRC on file %s\n",(char*)l_target_path,0,0,0,0,0 ); l_CopyIntegrity = OK; } else { //Read source file CRC if ( ERROR == ReadFileCRC(p_pList[l_i].m_pFileName, l_readCRC) ) { UPGLogMsg( "WARNING: Cannot read CRC of file %s\n",(char*)p_pList[l_i].m_pFileName,0,0,0,0,0 ); l_CopyIntegrity = OK; } else { //Compare if ( strcmp(l_readCRC, l_actualCRC) ) { UPGLogMsg( "ERROR: CRC of file %s differs after copy (%s -> %s)\n", (char*)l_target_path,(char*)l_readCRC,(char*)l_actualCRC,0,0,0 ); } else { //Copy succeded l_CopyIntegrity = OK; //Progress bargraph l_lCompletedSize += p_pList[l_i].m_iSize; l_percentage = (int) ( (l_lCompletedSize*100.0)/p_lTotalSize ); StepBargraph("1/2", l_percentage); taskDelay(50); } } } } else { l_CopyIntegrity = OK; } } } if (ERROR == l_CopyIntegrity) { UPGLogMsg( "FATAL COPY ERROR!!!\n",0,0,0,0,0,0 ); l_status = ERROR; break; } } if ( OK == l_status ) { *p_pCompletedSize = l_lCompletedSize; } return ( l_status ); } int FileExists(char *p_pPath) { FILE* l_pFich = NULL; if ( NULL == ( l_pFich = fopen (p_pPath,"r") ) ) { return(FALSE); } else { fclose(l_pFich); return(TRUE); } }
page revision: 1, last edited: 24 Jan 2008 00:45





