imgtools/romtools/rombuild/r_obey.cpp
changeset 626 ac03b93ca9c4
parent 590 360bd6b35136
child 647 53d1ab72f5bc
equal deleted inserted replaced
625:a1925fb7753a 626:ac03b93ca9c4
    39 #include "r_global.h"
    39 #include "r_global.h"
    40 #include "h_utl.h"
    40 #include "h_utl.h"
    41 #include "patchdataprocessor.h"
    41 #include "patchdataprocessor.h"
    42 #include "r_coreimage.h" 
    42 #include "r_coreimage.h" 
    43 
    43 
       
    44 #include "uniconv.hpp"
       
    45 extern TBool gIsOBYUTF8;
    44 #define _P(word)	word, sizeof(word)-1	// match prefix, optionally followed by [HWVD]
    46 #define _P(word)	word, sizeof(word)-1	// match prefix, optionally followed by [HWVD]
    45 #define _K(word)	word, 0					// match whole word
    47 #define _K(word)	word, 0					// match whole word
    46 static char* const NullString = "" ;
    48 static char* const NullString = "" ;
    47 const ObeyFileKeyword ObeyFileReader::iKeywords[] = {
    49 const ObeyFileKeyword ObeyFileReader::iKeywords[] = {
    48 	{_P("file"),		2,-2, EKeywordFile, "Executable file to be loaded into the ROM"},
    50 	{_P("file"),		2,-2, EKeywordFile, "Executable file to be loaded into the ROM"},
  1068 	if (isPeFile)
  1070 	if (isPeFile)
  1069 		iNumberOfPeFiles++;
  1071 		iNumberOfPeFiles++;
  1070 
  1072 
  1071 	// check the PC file exists
  1073 	// check the PC file exists
  1072 	char* nname = NormaliseFileName(iReader.Word(1)); 
  1074 	char* nname = NormaliseFileName(iReader.Word(1)); 
       
  1075 	if(gIsOBYUTF8 && !UniConv::IsPureASCIITextStream(nname))
       
  1076 	{
       
  1077 		char* tempnname = strdup(nname);
       
  1078 		unsigned int namelen = 0;
       
  1079 		if(UniConv::UTF82DefaultCodePage(tempnname, strlen(tempnname), &nname, &namelen) < 0)
       
  1080 		{
       
  1081 			Print(EError, "Invalid filename encoding: %s\n", tempnname);
       
  1082 			free(tempnname);
       
  1083 			iMissingFiles++;
       
  1084 			delete[] nname;
       
  1085 			return EFalse;
       
  1086 		}
       
  1087 		free(tempnname);
       
  1088 	}
  1073 	ifstream test(nname,ios_base::binary | ios_base::in); 
  1089 	ifstream test(nname,ios_base::binary | ios_base::in); 
  1074 
  1090 
  1075 	if (!test.is_open()) {
  1091 	if (!test.is_open()) {
  1076 		Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
  1092 		Print(EError,"Cannot open file %s for input.\n",iReader.Word(1));
  1077 		if(EKeywordHardwareConfigRepositoryData == aKeyword) {
  1093 		if(EKeywordHardwareConfigRepositoryData == aKeyword) {