57 #include "cache/cachevalidator.hpp" |
57 #include "cache/cachevalidator.hpp" |
58 #include "cache/cacheablelist.hpp" |
58 #include "cache/cacheablelist.hpp" |
59 #include "cache/cachemanager.hpp" |
59 #include "cache/cachemanager.hpp" |
60 |
60 |
61 #include "uniconv.hpp" |
61 #include "uniconv.hpp" |
62 |
|
63 #define MAX_LINE 65535 |
|
64 |
|
65 extern TUint checkSum(const void* aPtr); |
62 extern TUint checkSum(const void* aPtr); |
66 |
63 |
67 extern ECompression gCompress; |
64 extern ECompression gCompress; |
68 extern TUint gCompressionMethod; |
65 extern TUint gCompressionMethod; |
69 extern TInt gCodePagingOverride; |
66 extern TInt gCodePagingOverride; |
626 //Offset in 32bit words from start of file block |
623 //Offset in 32bit words from start of file block |
627 TUint32 offset = ((((TUint8*) entry) - fileBlockBase) >> 2); |
624 TUint32 offset = ((((TUint8*) entry) - fileBlockBase) >> 2); |
628 |
625 |
629 if(offset > 0xFFFF) |
626 if(offset > 0xFFFF) |
630 { |
627 { |
631 printf("ERROR: Offset overflow: name=%s, OFFSET = %d\n", node->iName, (unsigned int)offset); |
628 printf("ERROR: Offset overflow: name=%s, OFFSET = %d\n", node->iName, (int)offset); |
632 throw "fail"; |
629 throw "fail"; |
633 } |
630 } |
634 |
631 |
635 |
632 |
636 array[index].iOffset = (TUint16) offset; |
633 array[index].iOffset = (TUint16) offset; |
641 entry = pDirEntry; |
638 entry = pDirEntry; |
642 |
639 |
643 TUint32 offset = ((((TUint8*) entry) - dirBlockBase) >> 2); |
640 TUint32 offset = ((((TUint8*) entry) - dirBlockBase) >> 2); |
644 if(offset > 0xFFFF) |
641 if(offset > 0xFFFF) |
645 { |
642 { |
646 printf("ERROR: Offset overflow: name=%s, OFFSET = %d\n", node->iName, (unsigned int)offset); |
643 printf("ERROR: Offset overflow: name=%s, OFFSET = %d\n", node->iName, (int)offset); |
647 throw "fail"; |
644 throw "fail"; |
648 } |
645 } |
649 |
646 |
650 //Offset in 32bit words from start of directory block |
647 //Offset in 32bit words from start of directory block |
651 array[index].iOffset = (TUint16) offset; |
648 array[index].iOffset = (TUint16) offset; |
875 // |
861 // |
876 // Returns the number of bytes used, or -ve error code |
862 // Returns the number of bytes used, or -ve error code |
877 TInt TRomBuilderEntry::PlaceFile( TUint8* &aDest,TUint aMaxSize, CBytePair *aBPE ){ |
863 TInt TRomBuilderEntry::PlaceFile( TUint8* &aDest,TUint aMaxSize, CBytePair *aBPE ){ |
878 |
864 |
879 |
865 |
880 char tmpbuf[MAX_LINE]; |
|
881 TUint compression = 0; |
866 TUint compression = 0; |
882 TBool executable = iExecutable; |
867 TBool executable = iExecutable; |
883 sprintf(tmpbuf,"Reading file %s to image\n", iFileName ); |
868 Print(ELog,"Reading file %s to image\n", iFileName ); |
884 iLogMessages.push_back(tmpbuf); |
|
885 |
|
886 TUint32 size = HFile::GetLength(iFileName); |
869 TUint32 size = HFile::GetLength(iFileName); |
887 if (size==0) |
870 if (size==0) |
888 Print(EWarning, "File %s does not exist or is 0 bytes in length.\n",iFileName); |
871 Print(EWarning, "File %s does not exist or is 0 bytes in length.\n",iFileName); |
889 if (aDest == NULL) { |
872 if (aDest == NULL) { |
890 aMaxSize = size << 1; |
873 aMaxSize = size << 1; |
1085 if ( oldFileComp != newFileComp ) |
1068 if ( oldFileComp != newFileComp ) |
1086 { |
1069 { |
1087 |
1070 |
1088 if( newFileComp == 0) |
1071 if( newFileComp == 0) |
1089 { |
1072 { |
1090 sprintf(tmpbuf,"Decompressing executable '%s'\n", iFileName); |
1073 Print(ELog,"Decompressing executable '%s'\n", iFileName); |
1091 iLogMessages.push_back(tmpbuf); |
|
1092 f.iHdr->iCompressionType = 0; |
1074 f.iHdr->iCompressionType = 0; |
1093 } |
1075 } |
1094 else |
1076 else |
1095 { |
1077 { |
1096 sprintf(tmpbuf,"Compressing executable '%s' with method:%08x\n", iFileName, (unsigned int)newFileComp); |
1078 Print(ELog,"Compressing executable '%s' with method:%08x\n", iFileName, newFileComp); |
1097 iLogMessages.push_back(tmpbuf); |
|
1098 f.iHdr->iCompressionType = newFileComp; |
1079 f.iHdr->iCompressionType = newFileComp; |
1099 } |
1080 } |
1100 f.UpdateHeaderCrc(); |
1081 f.UpdateHeaderCrc(); |
1101 if (overflow) |
1082 if (overflow) |
1102 { |
1083 { |
1141 memcpy(aDest, entryref->GetCachedFileBuffer(), size); |
1122 memcpy(aDest, entryref->GetCachedFileBuffer(), size); |
1142 memcpy(aDest,f.iHdr,sizeof(E32ImageHeaderV)); |
1123 memcpy(aDest,f.iHdr,sizeof(E32ImageHeaderV)); |
1143 compression = atoi(entryref->GetCachedFileCompressionID()); |
1124 compression = atoi(entryref->GetCachedFileCompressionID()); |
1144 memcpy(&iUids[0], aDest, sizeof(iUids)); |
1125 memcpy(&iUids[0], aDest, sizeof(iUids)); |
1145 if (compression) |
1126 if (compression) |
1146 sprintf(tmpbuf,"Compressed executable File '%s' size: %08x, mode:%08x\n", iFileName, (unsigned int) size, (unsigned int)compression); |
1127 Print(ELog,"Compressed executable File '%s' size: %08x, mode:%08x\n", iFileName, size, compression); |
1147 else if (iExecutable) |
1128 else if (iExecutable) |
1148 sprintf(tmpbuf,"Executable File '%s' size: %08x\n", iFileName, (unsigned int)size); |
1129 Print(ELog,"Executable File '%s' size: %08x\n", iFileName, size); |
1149 else |
1130 else |
1150 sprintf(tmpbuf,"File '%s' size: %08x\n", iFileName, (unsigned int) size); |
1131 Print(ELog,"File '%s' size: %08x\n", iFileName, size); |
1151 iLogMessages.push_back(tmpbuf); |
|
1152 iRealFileSize = size; // required later when directory is written |
1132 iRealFileSize = size; // required later when directory is written |
1153 |
1133 |
1154 return size; |
1134 return size; |
1155 } |
1135 } |
1156 } |
1136 } |
1224 TUint32 Uidslen = (size > sizeof(iUids)) ? sizeof(iUids) : size; |
1204 TUint32 Uidslen = (size > sizeof(iUids)) ? sizeof(iUids) : size; |
1225 memcpy(&iUids[0], aDest, Uidslen); |
1205 memcpy(&iUids[0], aDest, Uidslen); |
1226 } |
1206 } |
1227 |
1207 |
1228 if (compression) |
1208 if (compression) |
1229 sprintf(tmpbuf,"Compressed executable File '%s' size: %08x, mode:%08x\n", iFileName, (unsigned int) size, (unsigned int) compression); |
1209 Print(ELog,"Compressed executable File '%s' size: %08x, mode:%08x\n", iFileName, size, compression); |
1230 else if (iExecutable) |
1210 else if (iExecutable) |
1231 sprintf(tmpbuf,"Executable File '%s' size: %08x\n", iFileName, (unsigned int) size); |
1211 Print(ELog,"Executable File '%s' size: %08x\n", iFileName, size); |
1232 else |
1212 else |
1233 sprintf(tmpbuf,"File '%s' size: %08x\n", iFileName, (unsigned int) size); |
1213 Print(ELog,"File '%s' size: %08x\n", iFileName, size); |
1234 iLogMessages.push_back(tmpbuf); |
|
1235 iCompressEnabled = compression; |
1214 iCompressEnabled = compression; |
1236 iRealFileSize = size; // required later when directory is written |
1215 iRealFileSize = size; // required later when directory is written |
1237 |
1216 |
1238 return size; |
1217 return size; |
1239 } |
1218 } |
1370 if(iFileName) |
1349 if(iFileName) |
1371 Print(aWhere, "%s\t%d\n", iFileName, RealFileSize()); |
1350 Print(aWhere, "%s\t%d\n", iFileName, RealFileSize()); |
1372 } |
1351 } |
1373 |
1352 |
1374 } |
1353 } |
|
1354 char* TRomBuilderEntry::GetSystemFullName() |
|
1355 { |
|
1356 TBool aIgnoreHiddenAttrib = ETrue; |
|
1357 TInt aLen = iRomNode->FullNameLength(aIgnoreHiddenAttrib); |
|
1358 char *aBuf = new char[aLen+1]; |
|
1359 iRomNode->GetFullName(aBuf, aIgnoreHiddenAttrib); |
|
1360 return aBuf; |
|
1361 } |