MCPcopy Create free account
hub / github.com/davisking/dlib / get_parent

Method get_parent

dlib/dir_nav/dir_nav_kernel_1.cpp:178–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176// ----------------------------------------------------------------------------------------
177
178 const directory directory::
179 get_parent (
180 ) const
181 {
182 using namespace std;
183 // if *this is the root then just return *this
184 if (is_root())
185 {
186 return *this;
187 }
188 else
189 {
190 directory temp;
191
192 const char sep = get_separator();
193
194 string::size_type pos = state.full_name.find_last_of(sep);
195 temp.state.full_name = state.full_name.substr(0,pos);
196
197 if ( is_root_path(temp.state.full_name))
198 {
199 temp.state.full_name += sep;
200 }
201 else
202 {
203 pos = temp.state.full_name.find_last_of(sep);
204 if (pos != string::npos)
205 {
206 temp.state.name = temp.state.full_name.substr(pos+1);
207 }
208 else
209 {
210 temp.state.full_name += sep;
211 }
212 }
213 return temp;
214 }
215 }
216
217// ----------------------------------------------------------------------------------------
218

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected