CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shortstring.cc
Go to the documentation of this file.
1 
8 #include "shortstring.h"
9 
10 #ifdef CVMFS_NAMESPACE_GUARD
11 namespace CVMFS_NAMESPACE_GUARD {
12 #endif
13 
15  int length = static_cast<int>(path.GetLength());
16  if (length == 0)
17  return path;
18  const char *chars = path.GetChars();
19 
20  for (int i = length - 1; i >= 0; --i) {
21  if (chars[i] == '/')
22  return PathString(chars, i);
23  }
24 
25  return path;
26 }
27 
29  NameString name;
30  int length = static_cast<int>(path.GetLength());
31  const char *chars = path.GetChars();
32 
33  int i;
34  for (i = length - 1; i >= 0; --i) {
35  if (chars[i] == '/')
36  break;
37  }
38  i++;
39  if (i < length) {
40  name.Append(chars + i, length - i);
41  }
42 
43  return name;
44 }
45 
46 #ifdef CVMFS_NAMESPACE_GUARD
47 } // namespace CVMFS_NAMESPACE_GUARD
48 #endif
NameString GetFileName(const PathString &path)
Definition: shortstring.cc:28
void Append(const char *chars, const unsigned length)
Definition: shortstring.h:80
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:213
PathString GetParentPath(const PathString &path)
Definition: shortstring.cc:14
unsigned GetLength() const
Definition: shortstring.h:131
const char * GetChars() const
Definition: shortstring.h:123