Added get_parent_directory()

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403859
This commit is contained in:
Davis King 2010-09-26 14:16:20 +00:00
parent 6efd2b750b
commit 6f2edac080
4 changed files with 64 additions and 2 deletions

View File

@ -34,6 +34,32 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const directory& dir
)
{
return dir.get_parent();
}
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const file& f
)
{
if (f.full_name().size() == 0)
return directory();
std::string::size_type pos = f.full_name().find_last_of("\\/");
if (pos == std::string::npos)
return directory();
return directory(f.full_name().substr(0,pos));
}
// ----------------------------------------------------------------------------------------
}

View File

@ -93,6 +93,18 @@ namespace dlib
) const { return true; }
};
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const directory& dir
);
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const file& f
);
// ----------------------------------------------------------------------------------------
}

View File

@ -91,6 +91,30 @@ namespace dlib
!*/
};
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const directory& dir
);
/*!
ensures
- returns the parent directory of dir. In particular, this
function returns the value of dir.get_parent()
!*/
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const file& f
);
/*!
ensures
- if (f.full_name() != "") then
- returns the directory which contains the given file
- else
- returns a default initialized directory (i.e. directory())
!*/
// ----------------------------------------------------------------------------------------
}

View File

@ -101,7 +101,7 @@ namespace dlib
);
/*!
ensures
- this function is idential to file(const std::string& name)
- this function is identical to file(const std::string& name)
!*/
file (
@ -243,7 +243,7 @@ namespace dlib
);
/*!
ensures
- this function is idential to directory(const std::string& name)
- this function is identical to directory(const std::string& name)
!*/
directory (