MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / getPathDepth

Function getPathDepth

radiantcore/vfs/GenericFileSystem.h:25–42  ·  view source on GitHub ↗

Returns the depth of a given path string, basically counting the number of parts in between forward slashes "" => 0 "dds/" => 1 "dds/textures/" => 2 "dds/textures/darkmod/" => 3 "dds/textures/darkmod/wood/" => 4 "dds/textures/darkmod/wood/boards/" => 5 "dds/textures/darkmod/wood/boards/dark_rough.dds" => 6

Source from the content-addressed store, hash-verified

23// "dds/textures/darkmod/wood/boards/" => 5
24// "dds/textures/darkmod/wood/boards/dark_rough.dds" => 6
25inline unsigned int getPathDepth(const char* path)
26{
27 unsigned int depth = 0;
28
29 while (path != 0 && path[0] != '\0')
30 {
31 path = strchr(path, '/');
32
33 if (path != 0)
34 {
35 ++path;
36 }
37
38 ++depth;
39 }
40
41 return depth;
42}
43
44}
45

Callers 2

PathMethod · 0.85
traverseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected