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

Function CalcAllowedDepth

Libraries/unrar/extinfo.cpp:78–93  ·  view source on GitHub ↗

Calculate a number of path components except \. and \..

Source from the content-addressed store, hash-verified

76
77// Calculate a number of path components except \. and \..
78static int CalcAllowedDepth(const wchar *Name)
79{
80 int AllowedDepth=0;
81 while (*Name!=0)
82 {
83 if (IsPathDiv(Name[0]) && Name[1]!=0 && !IsPathDiv(Name[1]))
84 {
85 bool Dot=Name[1]=='.' && (IsPathDiv(Name[2]) || Name[2]==0);
86 bool Dot2=Name[1]=='.' && Name[2]=='.' && (IsPathDiv(Name[3]) || Name[3]==0);
87 if (!Dot && !Dot2)
88 AllowedDepth++;
89 }
90 Name++;
91 }
92 return AllowedDepth;
93}
94
95
96// Check if all existing path components are directories and not links.

Callers 1

IsRelativeSymlinkSafeFunction · 0.85

Calls 1

IsPathDivFunction · 0.85

Tested by

no test coverage detected