CernVM-FS  2.12.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  // If parent is "", then any path is a subpath
11  if (parent.GetLength() == 0) {
12  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  if (path.StartsWith(parent) &&
19  ((path.GetLength() == parent.GetLength()) ||
20  (path.GetChars()[parent.GetLength()] == '/') ||
21  (path.GetChars()[parent.GetLength() - 1] == '/'))) {
22  return true;
23  }
24 
25  return false;
26 }
27 
28 } // namespace receiver
bool IsSubPath(const PathString &parent, const PathString &path)
bool StartsWith(const ShortString &other) const
Definition: shortstring.h:189
unsigned GetLength() const
Definition: shortstring.h:131
const char * GetChars() const
Definition: shortstring.h:123