libUTL++
Pathname.h
1 #pragma once
2 
4 
5 #include <libutl/String.h>
6 
8 
9 UTL_NS_BEGIN;
10 
30 
32 class Pathname : public String
33 {
36 
37 public:
42  Pathname(const String& pathname)
43  : String(pathname)
44  {
45  }
46 
51  Pathname(const char* pathname)
52  : String(pathname)
53  {
54  }
55 
57  Pathname directory() const;
58 
60  Pathname chopDirectory();
61 
63  Pathname filename() const;
64 
66  Pathname chopFilename();
67 
69  Pathname basename() const;
70 
72  Pathname chopBasename();
73 
75  String suffix() const;
76 
78  String chopSuffix();
79 
81  Pathname firstComponent() const;
82 
84  Pathname chopFirstComponent();
85 
87  Pathname lastComponent() const;
88 
90  Pathname chopLastComponent();
91 
93  bool isAbsolute() const;
94 
96  bool
97  isRelative() const
98  {
99  return !isAbsolute();
100  }
101 
107  void appendSeparator();
108 
113  void removeTrailingSeparator();
114 
119  void normalize();
120 
125  static char
127  {
128  return _separator;
129  }
130 
132  static void utl_init();
133 
134 private:
135  static char _separator;
136 };
137 
139 
140 UTL_NS_END;
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
Filesystem pathname.
Definition: Pathname.h:32
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Character string.
Definition: String.h:31
Pathname(const String &pathname)
Constructor.
Definition: Pathname.h:42
bool isRelative() const
Relative pathname?
Definition: Pathname.h:97
static char separator()
Get the path separator character.
Definition: Pathname.h:126
Pathname(const char *pathname)
Constructor.
Definition: Pathname.h:51