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

Function MakeNameCompatible

Libraries/unrar/pathfn.cpp:989–1008  ·  view source on GitHub ↗

Remove trailing spaces and dots in file name and in dir names in path.

Source from the content-addressed store, hash-verified

987
988// Remove trailing spaces and dots in file name and in dir names in path.
989void MakeNameCompatible(wchar *Name)
990{
991 int Src=0,Dest=0;
992 while (true)
993 {
994 if (IsPathDiv(Name[Src]) || Name[Src]==0)
995 for (int I=Dest-1;I>0 && (Name[I]==' ' || Name[I]=='.');I--)
996 {
997 // Permit path1/./path2 and ../path1 paths.
998 if (Name[I]=='.' && (IsPathDiv(Name[I-1]) || Name[I-1]=='.' && I==1))
999 break;
1000 Dest--;
1001 }
1002 Name[Dest]=Name[Src];
1003 if (Name[Src]==0)
1004 break;
1005 Src++;
1006 Dest++;
1007 }
1008}
1009#endif

Callers 1

ExtrPrepareNameMethod · 0.85

Calls 1

IsPathDivFunction · 0.85

Tested by

no test coverage detected