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 |
|
14 |
bool IsPathInLease(const PathString& lease, const PathString& path) { |
10 |
|
|
// If lease is "", any path falls within item |
11 |
✓✓ |
14 |
if (!strcmp(lease.c_str(), "")) { |
12 |
|
8 |
return true; |
13 |
|
|
} |
14 |
|
|
|
15 |
|
|
// Is the lease string is the prefix of the path string and the next |
16 |
|
|
// character of the path string is a "/". |
17 |
✓✓✓✓ ✓✓ |
6 |
if (path.StartsWith(lease) && path.GetChars()[lease.GetLength()] == '/') { |
18 |
|
1 |
return true; |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
// If the path string is exactly the lease path return true (allow the |
22 |
|
|
// creation of the leased directory during the lease itself) |
23 |
✓✓ |
5 |
if (lease == path) { |
24 |
|
1 |
return true; |
25 |
|
|
} |
26 |
|
|
|
27 |
|
4 |
return false; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
} // namespace receiver |