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
| 23 | // "dds/textures/darkmod/wood/boards/" => 5 |
| 24 | // "dds/textures/darkmod/wood/boards/dark_rough.dds" => 6 |
| 25 | inline 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 |