Directory: | cvmfs/ |
---|---|
File: | cvmfs/receiver/lease_path_util.cc |
Date: | 2025-06-01 02:36:00 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 9 | 9 | 100.0% |
Branches: | 11 | 12 | 91.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /** | ||
2 | * This file is part of the CernVM File System. | ||
3 | */ | ||
4 | |||
5 | #include "lease_path_util.h" | ||
6 | |||
7 | namespace receiver { | ||
8 | |||
9 | 44 | bool IsSubPath(const PathString &parent, const PathString &path) { | |
10 | // If parent is "", then any path is a subpath | ||
11 |
2/2✓ Branch 1 taken 38 times.
✓ Branch 2 taken 6 times.
|
44 | if (parent.GetLength() == 0) { |
12 | 38 | return true; | |
13 | } | ||
14 | |||
15 | // If the parent string is the prefix of the path string and either | ||
16 | // the strings are identical or the separator character is a "/", | ||
17 | // then the path is a subpath | ||
18 | 6 | if (path.StartsWith(parent) | |
19 |
6/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 4 times.
|
8 | && ((path.GetLength() == parent.GetLength()) |
20 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
2 | || (path.GetChars()[parent.GetLength()] == '/') |
21 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | || (path.GetChars()[parent.GetLength() - 1] == '/'))) { |
22 | 2 | return true; | |
23 | } | ||
24 | |||
25 | 4 | return false; | |
26 | } | ||
27 | |||
28 | } // namespace receiver | ||
29 |