@@ -49,6 +49,26 @@ std::vector<std::string> split(const std::string& s, char seperator)
49
49
return output;
50
50
}
51
51
52
+ void ReplaceSpecialsChars (std::string& sString )
53
+ {
54
+ ReplaceAll (sString , " ." , " _" );
55
+ ReplaceAll (sString , " " , " _" );
56
+ ReplaceAll (sString , " -" , " _" );
57
+ ReplaceAll (sString , " +" , " _" );
58
+ ReplaceAll (sString , " *" , " _" );
59
+ ReplaceAll (sString , " /" , " _" );
60
+ ReplaceAll (sString , " %" , " _" );
61
+ ReplaceAll (sString , " <" , " _" );
62
+ ReplaceAll (sString , " >" , " _" );
63
+ ReplaceAll (sString , " &" , " _" );
64
+ ReplaceAll (sString , " !" , " _" );
65
+ ReplaceAll (sString , " =" , " _" );
66
+ ReplaceAll (sString , " (" , " _" );
67
+ ReplaceAll (sString , " )" , " _" );
68
+ ReplaceAll (sString , " [" , " _" );
69
+ ReplaceAll (sString , " ]" , " _" );
70
+ }
71
+
52
72
void PrintRow (FILE* dst, const unsigned char * buf, unsigned count)
53
73
{
54
74
fprintf (dst, " \n " );
@@ -94,7 +114,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
94
114
{
95
115
char * pCompressed = (char *)malloc (iCompressBound);
96
116
iCompressedSize = LZ4_compress_default (pData, pCompressed, iOriginSize, iCompressBound);
97
-
117
+
98
118
if (iCompressedSize >= iOriginSize)
99
119
{
100
120
printf (" Useless compression for this file\n " );
@@ -173,24 +193,24 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
173
193
std::string sIndent (iIndent, ' \t ' );
174
194
std::string sIndentP (iIndent + 1 , ' \t ' );
175
195
std::string sIndentPP (iIndent + 2 , ' \t ' );
176
-
196
+
177
197
178
198
std::string sName = pName;
179
- ReplaceAll (sName , " ." , " _" );
180
- ReplaceAll (sName , " " , " _" );
199
+ ReplaceSpecialsChars (sName );
181
200
182
201
std::string sDefine = " __RESOURCES_" ;
183
202
if (NULL != pRelativePath)
184
203
{
185
- sDefine += pRelativePath;
204
+ std::string sRelativePath ;
205
+ ReplaceSpecialsChars (sRelativePath );
206
+
207
+ sDefine += sRelativePath ;
186
208
sDefine += " _" ;
187
209
}
188
210
sDefine += sName ;
189
211
sDefine += " _H__" ;
190
212
std::transform (sDefine .begin (), sDefine .end (), sDefine .begin (), ::toupper);
191
- ReplaceAll (sDefine , " ." , " _" );
192
- ReplaceAll (sDefine , " " , " _" );
193
- ReplaceAll (sDefine , " /" , " _" );
213
+ ReplaceSpecialsChars (sDefine );
194
214
195
215
fprintf (pHeaderFile, " #ifndef %s\n " , sDefine .c_str ());
196
216
fprintf (pHeaderFile, " #define %s\n\n " , sDefine .c_str ());
@@ -200,8 +220,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
200
220
for (size_t iNamespace = 0 ; iNamespace < oNamespaces.size (); ++iNamespace)
201
221
{
202
222
std::string sNamespace = oNamespaces[iNamespace];
203
- ReplaceAll (sDefine , " ." , " _" );
204
- ReplaceAll (sDefine , " " , " _" );
223
+ ReplaceSpecialsChars (sNamespace );
205
224
std::string sNamespaceIndent (iNamespace, ' \t ' );
206
225
fprintf (pHeaderFile, " %snamespace %s \n %s{\n " , sNamespaceIndent .c_str (), sNamespace .c_str (), sNamespaceIndent .c_str ());
207
226
fprintf (pSourceFile, " %snamespace %s \n %s{\n " , sNamespaceIndent .c_str (), sNamespace .c_str (), sNamespaceIndent .c_str ());
@@ -253,7 +272,7 @@ void ExportFile(const char* pName, const char* pInputFilename, const char* pOutp
253
272
if (iPos < (iSize - 1 ))
254
273
fprintf (pSourceFile, " ," );
255
274
}
256
-
275
+
257
276
fprintf (pSourceFile, " \n %s};\n " , sIndentP .c_str ());
258
277
259
278
// Closing namespaces
@@ -319,8 +338,7 @@ void ScanFolder(const char* pInputFolder, const char* pOutputFolderBase, const c
319
338
}
320
339
sOutPath += " /" ;
321
340
std::string sName = file.name ;
322
- ReplaceAll (sName , " ." , " _" );
323
- ReplaceAll (sName , " " , " _" );
341
+ ReplaceSpecialsChars (sName );
324
342
sOutPath += sName ;
325
343
326
344
ExportFile (file.name , file.path , sOutPath .c_str (), pOutputRelative, eCompressMode);
@@ -379,7 +397,7 @@ void main(int argn, char** argv)
379
397
printf (" Invalid argument" );
380
398
return ;
381
399
}
382
-
400
+
383
401
++iArg;
384
402
}
385
403
0 commit comments