| 433 | |
| 434 | |
| 435 | void MakeNameUsable(char *Name,bool Extended) |
| 436 | { |
| 437 | #ifdef _WIN_ALL |
| 438 | // In Windows we also need to convert characters not defined in current |
| 439 | // code page. This double conversion changes them to '?', which is |
| 440 | // catched by code below. |
| 441 | size_t NameLength=strlen(Name); |
| 442 | wchar NameW[NM]; |
| 443 | CharToWide(Name,NameW,ASIZE(NameW)); |
| 444 | WideToChar(NameW,Name,NameLength+1); |
| 445 | Name[NameLength]=0; |
| 446 | #endif |
| 447 | for (char *s=Name;*s!=0;s=charnext(s)) |
| 448 | { |
| 449 | if (strchr(Extended ? "?*<>|\"":"?*",*s)!=NULL || Extended && (byte)*s<32) |
| 450 | *s='_'; |
| 451 | #ifdef _EMX |
| 452 | if (*s=='=') |
| 453 | *s='_'; |
| 454 | #endif |
| 455 | #ifndef _UNIX |
| 456 | if (s-Name>1 && *s==':') |
| 457 | *s='_'; |
| 458 | // Remove ' ' and '.' before path separator, but allow .\ and ..\. |
| 459 | if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1])) |
| 460 | *s='_'; |
| 461 | #endif |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | |
| 466 | void MakeNameUsable(wchar *Name,bool Extended) |
no test coverage detected