Commit 6f2edac0 authored by Davis King's avatar Davis King

Added get_parent_directory()

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403859
parent 6efd2b75
......@@ -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));
}
// ----------------------------------------------------------------------------------------
}
......
......@@ -93,6 +93,18 @@ namespace dlib
) const { return true; }
};
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const directory& dir
);
// ----------------------------------------------------------------------------------------
directory get_parent_directory (
const file& f
);
// ----------------------------------------------------------------------------------------
}
......
......@@ -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())
!*/
// ----------------------------------------------------------------------------------------
}
......
......@@ -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 (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment