CernVM-FS  2.11.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 "cvmfs_config.h"
9 #include "shortstring.h"
10 
11 #ifdef CVMFS_NAMESPACE_GUARD
12 namespace CVMFS_NAMESPACE_GUARD {
13 #endif
14 
16  int length = static_cast<int>(path.GetLength());
17  if (length == 0)
18  return path;
19  const char *chars = path.GetChars();
20 
21  for (int i = length-1; i >= 0; --i) {
22  if (chars[i] == '/')
23  return PathString(chars, i);
24  }
25 
26  return path;
27 }
28 
30  NameString name;
31  int length = static_cast<int>(path.GetLength());
32  const char *chars = path.GetChars();
33 
34  int i;
35  for (i = length-1; i >= 0; --i) {
36  if (chars[i] == '/')
37  break;
38  }
39  i++;
40  if (i < length) {
41  name.Append(chars+i, length-i);
42  }
43 
44  return name;
45 }
46 
47 #ifdef CVMFS_NAMESPACE_GUARD
48 } // namespace CVMFS_NAMESPACE_GUARD
49 #endif
NameString GetFileName(const PathString &path)
Definition: shortstring.cc:29
void Append(const char *chars, const unsigned length)
Definition: shortstring.h:80
ShortString< kDefaultMaxPath, 0 > PathString
Definition: shortstring.h:202
PathString GetParentPath(const PathString &path)
Definition: shortstring.cc:15
unsigned GetLength() const
Definition: shortstring.h:116
const char * GetChars() const
Definition: shortstring.h:108