MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / MakeNameUsable

Function MakeNameUsable

Libraries/unrar/pathfn.cpp:435–463  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433
434
435void 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
466void MakeNameUsable(wchar *Name,bool Extended)

Callers 2

ExtrCreateDirMethod · 0.85
ExtrCreateFileMethod · 0.85

Calls 4

CharToWideFunction · 0.85
WideToCharFunction · 0.85
charnextFunction · 0.85
IsPathDivFunction · 0.85

Tested by

no test coverage detected