Changeset 6974c97 in OpenModelica
- Timestamp:
- 2022-05-20T21:07:04+02:00 (2 years ago)
- Branches:
- maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master
- Children:
- 981c083, c88cc982
- Parents:
- 54d7d41c
- git-author:
- Andreas <38031952+AnHeuermann@…> (05/20/22 21:07:04)
- git-committer:
- GitHub <noreply@…> (05/20/22 21:07:04)
- Location:
- OMCompiler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/runtime/System_omc.c
rbfad4b6b r6974c97 406 406 407 407 #if defined(__MINGW32__) || defined(_MSC_VER) 408 void* System_moFiles(const char *directory) 408 /** 409 * @brief Scan directory for package files with given pattern except for packageName. 410 * 411 * @param directory Directory to search in 412 * @param pattern Pattern to search for, e.g. "*.mo" or "*.moc". 413 * @param packageName Name of packages, e.g. "package.mo" or "package.moc" 414 * @return void* List of file names matching pattern. 415 */ 416 void* omc_scanDirForPackagePattern(const char* directory, const char* pattern, const wchar_t* packageName) 409 417 { 410 418 void *res; 411 WIN32_FIND_DATA FileData;419 WIN32_FIND_DATAW FileData; 412 420 BOOL more = TRUE; 413 char pattern[1024];414 421 HANDLE sh; 415 sprintf(pattern, "%s\\*.mo", directory); 422 char pattern_mb[1024]; 423 424 // TODO: Use longabspath for path longer than MAX_PATH 425 //wchar_t* unicodeAbsDirectory = longabspath(directory); 426 sprintf(pattern_mb, "%s\\%s", directory, pattern); 427 428 MULTIBYTE_TO_WIDECHAR_LENGTH(pattern_mb, pattern_uc_length); 429 MULTIBYTE_TO_WIDECHAR_VAR(pattern_mb, pattern_uc, pattern_uc_length); 430 416 431 res = mmc_mk_nil(); 417 sh = FindFirstFile (pattern, &FileData);432 sh = FindFirstFileW(pattern_uc, &FileData); 418 433 if (sh != INVALID_HANDLE_VALUE) { 419 434 while(more) { 420 if ( strcmp(FileData.cFileName,"package.mo") != 0)435 if (wcscmp(FileData.cFileName, packageName) != 0) 421 436 { 422 res = mmc_mk_cons(mmc_mk_scon(FileData.cFileName),res); 437 WIDECHAR_TO_MULTIBYTE_LENGTH(FileData.cFileName, file_name_mb_length); 438 WIDECHAR_TO_MULTIBYTE_VAR(FileData.cFileName, file_name_mb, file_name_mb_length); 439 440 res = mmc_mk_cons(mmc_mk_scon(file_name_mb),res); 441 MULTIBYTE_OR_WIDECHAR_VAR_FREE(file_name_mb); 423 442 } 424 more = FindNextFile (sh, &FileData);443 more = FindNextFileW(sh, &FileData); 425 444 } 426 445 if (sh != INVALID_HANDLE_VALUE) FindClose(sh); 427 446 } 428 return res; 447 448 MULTIBYTE_OR_WIDECHAR_VAR_FREE(pattern_uc); 449 450 return res; 451 } 452 #endif 453 454 /** 455 * @brief Scan directory for .mo files excluding package.mo. 456 * 457 * @param directory Directory to search in. 458 * @return void* List of file names. 459 */ 460 void* System_moFiles(const char *directory) 461 #if defined(__MINGW32__) || defined(_MSC_VER) 462 { 463 return omc_scanDirForPackagePattern(directory, "*.mo", L"package.mo"); 429 464 } 430 465 #else 431 void* System_moFiles(const char *directory)432 466 { 433 467 int i,count; … … 447 481 #endif 448 482 483 /** 484 * @brief Scan directory for .moc files excluding package.moc. 485 * 486 * @param directory Directory to search in. 487 * @return void* List of file names. 488 */ 489 void* System_mocFiles(const char *directory) 449 490 #if defined(__MINGW32__) || defined(_MSC_VER) 450 void* System_mocFiles(const char *directory) 451 { 452 void *res; 453 WIN32_FIND_DATA FileData; 454 BOOL more = TRUE; 455 char pattern[1024]; 456 HANDLE sh; 457 sprintf(pattern, "%s\\*.moc", directory); 458 res = mmc_mk_nil(); 459 sh = FindFirstFile(pattern, &FileData); 460 if (sh != INVALID_HANDLE_VALUE) { 461 while(more) { 462 if (strcmp(FileData.cFileName,"package.moc") != 0) 463 { 464 res = mmc_mk_cons(mmc_mk_scon(FileData.cFileName),res); 465 } 466 more = FindNextFile(sh, &FileData); 467 } 468 if (sh != INVALID_HANDLE_VALUE) FindClose(sh); 469 } 470 return res; 491 { 492 return omc_scanDirForPackagePattern(directory, "*.moc", L"package.moc"); 471 493 } 472 494 #else 473 void* System_mocFiles(const char *directory)474 495 { 475 496 int i,count; -
OMCompiler/SimulationRuntime/c/util/omc_file.h
rf11277c4 r6974c97 103 103 104 104 int omc_unlink(const char *filename); 105 #if defined(__MINGW32__) || defined(_MSC_VER) 106 wchar_t* longabspath(wchar_t* unicodePath); 107 #endif 105 108 106 109 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.