/////////////////////////////////////////////////////////////////////
| 344 | |
| 345 | ////////////////////////////////////////////////////////////////////////// |
| 346 | bool ResourceCompiler::CompileFile( const char *filename, const char *outroot, const char *outpath ) |
| 347 | { |
| 348 | CmdLine cmdLine; |
| 349 | |
| 350 | if (!RCPathFileExists(filename)) |
| 351 | return false; |
| 352 | |
| 353 | // get file extension. |
| 354 | CString ext = Path::GetExt(filename); |
| 355 | |
| 356 | // get key for special copy/ignore options to certain extensions |
| 357 | CString extkey = "ext_"; |
| 358 | extkey += ext; |
| 359 | CString extcommand; |
| 360 | m_config->Get(extkey.GetString(), extcommand); |
| 361 | |
| 362 | if(extcommand=="ignore") |
| 363 | { |
| 364 | Log("Ignoring %s", filename); |
| 365 | return true; |
| 366 | }; |
| 367 | |
| 368 | if(extcommand=="copy") |
| 369 | { |
| 370 | CString dest = outpath; |
| 371 | dest += Path::GetFile(filename); |
| 372 | if(dest!=filename) |
| 373 | { |
| 374 | // TODO: can compare filestamps of source and destination to avoid copy, but maybe overkill |
| 375 | Log("Copying %s to %s", filename, dest.GetString()); |
| 376 | CopyFile(filename, dest.GetString(), false); // overwrites any existing file, same as all converters |
| 377 | }; |
| 378 | return true; |
| 379 | }; |
| 380 | |
| 381 | // find convertor matching platform and extension. |
| 382 | IConvertor *conv = m_extensionManager.FindConvertor( m_platform,ext.GetString() ); |
| 383 | if (!conv) |
| 384 | { |
| 385 | // no convertor for this file. |
| 386 | return false; |
| 387 | } |
| 388 | |
| 389 | CString sourcePath = Path::GetPath(filename); |
| 390 | |
| 391 | CfgFile CfgFile; // file specifig config file |
| 392 | |
| 393 | CString defFile = Path::ReplaceExtension(filename,DEF_FILE_EXTENSION); |
| 394 | |
| 395 | CfgFile.SetFileName(defFile); |
| 396 | |
| 397 | Config localConfig; |
| 398 | |
| 399 | // Check if definition file exist for specified filename |
| 400 | if (RCPathFileExists(defFile.GetString())) |
| 401 | if (CfgFile.Load( defFile )) |
| 402 | { |
| 403 | CfgFile.SetConfig( COMMON_SECTION,localConfig.GetInternalRepresentation() ); |
nothing calls this directly
no test coverage detected