CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lease_path_util.cc
Go to the documentation of this file.
1 
5 #include "lease_path_util.h"
6 
7 namespace receiver {
8 
9 bool IsSubPath(const PathString& parent, const PathString& path) {
10 
11  // If parent is "", then any path is a subpath
12  if (parent.GetLength() == 0) {
13  return true;
14  }
15 
16  // If the parent string is the prefix of the path string and either
17  // the strings are identical or the separator character is a "/",
18  // then the path is a subpath
19  if (path.StartsWith(parent) &&
20  ((path.GetLength() == parent.GetLength()) ||
21  (path.GetChars()[parent.GetLength()] == '/') ||
22  (path.GetChars()[parent.GetLength() - 1] == '/'))) {
23  return true;
24  }
25 
26  return false;
27 }
28 
29 } // namespace receiver
bool IsSubPath(const PathString &parent, const PathString &path)
bool StartsWith(const ShortString &other) const
Definition: shortstring.h:161
unsigned GetLength() const
Definition: shortstring.h:103
const char * GetChars() const
Definition: shortstring.h:96