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

Method get_parent

dlib/dir_nav/dir_nav_kernel_2.cpp:194–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192// ----------------------------------------------------------------------------------------
193
194 const directory directory::
195 get_parent (
196 ) const
197 {
198 using namespace std;
199 // if *this is the root then just return *this
200 if (is_root())
201 {
202 return *this;
203 }
204 else
205 {
206 directory temp;
207
208 const char sep = get_separator();
209
210 string::size_type pos = state.full_name.find_last_of(sep);
211 temp.state.full_name = state.full_name.substr(0,pos);
212
213 if ( is_root_path(temp.state.full_name))
214 {
215 temp.state.full_name += sep;
216 }
217 else
218 {
219 pos = temp.state.full_name.find_last_of(sep);
220 if (pos != string::npos)
221 {
222 temp.state.name = temp.state.full_name.substr(pos+1);
223 }
224 else
225 {
226 temp.state.full_name += sep;
227 }
228 }
229 return temp;
230 }
231 }
232
233// ----------------------------------------------------------------------------------------
234

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected